How to make sure that after the player’s movement and playing the motion animation, the animation of the rack (Idle) starts, this should work in both directions (right, left)
I think alternatively, you can also use else
instead of an if statement, it makes the code cleaner that way:
var right_move = (keyboard_check(ord("D")));
var left_move = (keyboard_check(ord("A")));
if (right_move) {
phy_position_x += 10;
sprite_index = Move_right;
image_speed = 1;
} else {
sprite_index = Idle_right;
}
if (left_move) {
phy_position_x -= 10;
sprite_index = Move_left;
image_speed = 1;
} else {
sprite_index = Idle_left;
}
If the left sprite is the same as the right sprite, then you can also use image_xscale
and change the scale to 1
or -1
to flip the sprite.