How to do a constantly attack while jump sprite animation?

C

clyver

Guest
I've trying to do this for a while. I want to the jumping sprite change when the player is jumping and falling. I tried a lot of things but mostly of them didn't work out well. Here's the code I've put on the Player's Input Event
Code:
if (!place_meeting(x,y+1,OBloco2)) && (keyboard_check(ord("X")))
{

      if(sign(vsp) > 0)
    {
    sprite_index = SPiresAtP;
    }
    else
    {
    sprite_index = SPiresAtA;
    }
}
else
    {
        if (hsp == 0)
        {
            if (keyboard_check(ord("X")))
            {
            sprite_index = SPiresAt;
            image_speed = 0.75;
            }
            else
            {
       
    sprite_index = SPires;
        }
       
       
       
    }

}
I want the player to have a sprite animation playing while jumping and attacking, that one being SPiresAtP, and a sprite animation while falling and attacking, that one being SPiresAtA. "X" is the key for attack.
 

TheouAegis

Member
You really should look up State machines. Because as soon as the player let's go of the x key he's going to stop attacking with your code. Otherwise your code is just going to get messy hair and mess your as you try to work this out and then move on to the next set of actions.

 
C

clyver

Guest
You really should look up State machines. Because as soon as the player let's go of the x key he's going to stop attacking with your code. Otherwise your code is just going to get messy hair and mess your as you try to work this out and then move on to the next set of actions.

Thank you
 
Top