• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

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