KPJ
Member
Hi everyone. I have an issue with setting up the animations in my game (I am using Gamemaker Studio 2). I am creating a top-down game, and so far I have three player sprites: Idle, Walk and Stealth Attack.
The Player's Idle and Walk sprites are working correctly (when the player is moving, the sprite is set to Walk, and when it's not moving, it is set to Idle)
However, the Stealth Attack animation is not working. I want it to be so that when the player presses the space bar, the sprite will change to the Attack sprite (which has 5 frames).
When I press the space bar, it only plays the first frame of my Attack animation, then it goes back to the sprite it was before. (If my sprite is Idle and i press space bar, it will only play the first frame of the Attack animation before going back to Idle)
Does anyone know whats wrong? Thanks!
Code:
The Player's Idle and Walk sprites are working correctly (when the player is moving, the sprite is set to Walk, and when it's not moving, it is set to Idle)
However, the Stealth Attack animation is not working. I want it to be so that when the player presses the space bar, the sprite will change to the Attack sprite (which has 5 frames).
When I press the space bar, it only plays the first frame of my Attack animation, then it goes back to the sprite it was before. (If my sprite is Idle and i press space bar, it will only play the first frame of the Attack animation before going back to Idle)
Does anyone know whats wrong? Thanks!
Code:
Code:
//Player Step Event
if (keyboard_check(ord("W"))) || (keyboard_check(ord("A"))) || (keyboard_check(ord("S"))) || (keyboard_check(ord("D")))
{
sprite_index = sPlayerWalk;
}
else
{
sprite_index = sPlayerIdle;
}
if (keyboard_check_pressed(vk_space))
{
image_speed = 1;
sprite_index = sPlayerStealthAttack;
}
Code:
//Player Animation End
if (sprite_index == sPlayerStealthAttack)
{
sprite_index = sPlayerIdle;
}