K
Kdkreig
Guest
I'm currently experimenting with GMS2 and I'm essentially doing that with the SNES Link to the Past sprites. I have movement and I can make Link swing his sword. The main problem is that I can't find a way that I understand that makes it so that his sword swing animation happens only once and returns him back to the standing sprite and not that swinging sprite animation.
This is all the code that makes Link work
The code should be mostly organized. The commented code is just so that I can work on one piece at a time and not worry about other stuff possibly breaking. If it was unclear above then here. I'm currently trying to get it so that when I push space bar the attack animation does 1 loop and stops then returns link back to his standing position.
This is all the code that makes Link work
Code:
//movement
if (keyboard_check(vk_down))
{
y += 4;
sprite_index = spr_Link_WalkDown;
}
if (keyboard_check(vk_up))
{
y -= 4;
sprite_index = spr_Link_WalkUp;
}
if (keyboard_check(vk_left))
{
x -= 4;
sprite_index = spr_Link_WalkLeft;
}
if(keyboard_check(vk_right))
{
x += 4;
sprite_index = spr_Link_WalkRight;
}
if(keyboard_check_released(vk_right)) sprite_index = spr_Link_StandRight;
if(keyboard_check_released(vk_up)) sprite_index = spr_Link_StandUp;
if(keyboard_check_released(vk_left)) sprite_index = spr_Link_StandLeft;
if(keyboard_check_released(vk_down)) sprite_index = spr_Link_StandDown;
//attack animations
if(keyboard_check(vk_space)) && (sprite_index = spr_Link_StandDown)
{
sprite_index = spr_Link_SwordSwingDown;
}
//if(keyboard_check_released(vk_space) && sprite_index = spr_Link_SwordSwingDown) sprite_index = spr_Link_StandDown;
//if(keyboard_check(vk_space) && sprite_index = spr_Link_StandLeft) sprite_index = spr_Link_SwordSwingLeft;
//if(keyboard_check_released(vk_space) && sprite_index = spr_Link_SwordSwingLeft) sprite_index = spr_Link_StandLeft;