Change Sprites during jump cycle

Pkirkby

Member
Hey everyone, learning some platforming basics and I'm hoping to make my jump look smoother. When the player leaves the ground I want a certain frame of animation and then when he's a certain height it swaps to the next, when he reaches his max height, I want to swap to the next etc. And furthermore, when coming down from max height (Or I suppose depending on how close he is to the floor) I want it to swap to the final falling frame, then when landing play the last frame.

I know this can't be too difficult, but some guidance would help save me alot of time.

Currently I have some basic code to check if the player has is not on the ground, this was done via a tutorial, but I imagine there may be a better way to do that too. Thanks!
 

Attachments

TheouAegis

Member
You don't want image_speed. The simplest way short of using alarms/timer is to check vspeed every step and set the sprite based on that. But your sprite looks like you would want just alarms or both alarms and vspeed checks.
 

Pkirkby

Member
You don't want image_speed. The simplest way short of using alarms/timer is to check vspeed every step and set the sprite based on that. But your sprite looks like you would want just alarms or both alarms and vspeed checks.
I'll look into alarms and see how I can make them work, I tried them a long time ago but can't recall if I ever figured them out before I took a break from GMS2. Thanks
 

Pkirkby

Member
Found a solution using simple esle-if statements.

if (vsp > -7 && vsp < -6.5)
{
image_index = 1;
}
else if (vsp > -6 && vsp < -4)
{
image_index = 2;
}
else if (vsp > -5 && vsp < -3)
{
image_index = 3;
}
else if (vsp > -3 && vsp < -2)
{
image_index = 4;
}
else if (vsp > -2 && vsp < 7)
{
image_index = 5;
}
else
{
image_index = 5;
}
 
Last edited:
Top