In the script its supposed to run the animation line 6-8 currently and then its supposed to see if down is not pressed and the direction is down then set the sprite to look down Line 23-25 but it keeps playing the animation `x = PlayerObject.x; y = PlayerObject.y;
Direction = "";
if (keyboard_check(vk_down)) {
Direction = "Down";
sprite_index = CaseyDownWalk;
}
else if (keyboard_check(vk_right)) {
Direction = "Right";
sprite_index = CaseyRight;
}
else if (keyboard_check(vk_up)) {
Direction = "Up";
sprite_index = CaseyUp;
}
else if (keyboard_check(vk_left)) {
Direction = "Left";
sprite_index = CaseyLeft;
}
if not (keyboard_check(vk_down)) {
if (Direction == "Down") {
sprite_index = CaseyDown;
}
}
i tried changing up the code and what its supposed to do is to play the walking animation then repeat until key not pressed then set the animation to stop
In your code snippet, the line where it says
sprite_index = CaseyDown;will never be executed.In the beginning, you set
Direction = "". When the down button is released (and no other button pressed) it will thus still beDirection = "", and the conditionif (Direction == "Down")can't be true.An alternative would be the following: Instead of the direction, you check if you are NOT moving. Then you check which button was released using
if keyboard_check_released(vk_down):