• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GML having a hard time properly setting speed to 0

C

Capptianm

Guest
In my game, I've decided to handle walk animations like this: the animation is started by pressing the movement buttons, but the animation is ended by this piece of code in an animation end event so that the animation stops at the end of it:
Code:
if !(keyboard_check(ord("W")))
    {
        image_speed = 0
    }
    else if !(keyboard_check(ord("A")))
    {
        image_speed = 0
    }
    else if !(keyboard_check(ord("S")))
    {
        image_speed = 0
    }
    else if !(keyboard_check(ord("D")))
    {
        image_speed = 0
    }
the problem is that it stops the animation at the end of the animation no matter if a key is pressed or not. can someone help me out?
 

Kyon

Member
Yeah so, what your code now says is;
if I'm not pressing W, imagespeed is 0.
But if I AM pressing W, but I am not Pressing A, image speed is 0.
But if I AM pressing W AND A, but I am not pressing S, image speed is 0.
etc.

I'm assuming this is in animation end event or something?
You could just do image_speed=0;
and in your step event something like:
Code:
if (keyboard_check(ord("W")) || keyboard_check(ord("A")) || keyboard_check(ord("S")) || keyboard_check(ord("D")) ){image_speed=1;}
Hope that helps.
 
C

Capptianm

Guest
Yeah so, what your code now says is;
if I'm not pressing W, imagespeed is 0.
But if I AM pressing W, but I am not Pressing A, image speed is 0.
But if I AM pressing W AND A, but I am not pressing S, image speed is 0.
etc.

I'm assuming this is in animation end event or something?
You could just do image_speed=0;
and in your step event something like:
Code:
if (keyboard_check(ord("W")) || keyboard_check(ord("A")) || keyboard_check(ord("S")) || keyboard_check(ord("D")) ){image_speed=1;}
Hope that helps.
that did work, thanks!
 
Top