• 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!

Legacy GM My falling sprite won't animate?

S

Spin Attaxx

Guest
So I've made a spriteset that act as a transition from my player's jumping sprite to their falling one. The sprite is four subimages long, and I've programmed it so that when my player's vertical speed is greater than or equal to 0 (so when they stop gaining height and start falling down) it switches from my jump sprite to my falling sprite.

Now, this part works... but it only plays the first frame without going beyond that. I haven't done anything with this sprite's image_speed; so far as I know, it should be set to 1 by default and loop constantly until I specify when it stops or when it changes to another sprite index. Even if I set it to 1 or 0.5 or whatever in my player's Step event like with my run animation, it only displays the first image. I even checked the sprites themselves, and they don't have any problems. I don't know what's causing this.

Code:
if (grounded != true)
{
    if (vsp < 0) sprite_index = spr_player_jump;
    if (vsp >= 0) sprite_index = spr_player_fall;
}
 
F

fxokz

Guest
So I've made a spriteset that act as a transition from my player's jumping sprite to their falling one. The sprite is four subimages long, and I've programmed it so that when my player's vertical speed is greater than or equal to 0 (so when they stop gaining height and start falling down) it switches from my jump sprite to my falling sprite.

Now, this part works... but it only plays the first frame without going beyond that. I haven't done anything with this sprite's image_speed; so far as I know, it should be set to 1 by default and loop constantly until I specify when it stops or when it changes to another sprite index. Even if I set it to 1 or 0.5 or whatever in my player's Step event like with my run animation, it only displays the first image. I even checked the sprites themselves, and they don't have any problems. I don't know what's causing this.

Use
Code:
else if
 

chance

predictably random
Forum Staff
Moderator
I haven't done anything with this sprite's image_speed; so far as I know...(snip)
But you have. Setting image_speed to 0 anywhere in that instance's code will affect any sprite you happen to assign, until you change image_speed back to 1. So you've probably set it to 0 somewhere else in the step event for a different sprite, and forgot about it.

So explicitly reset it to 1 when you assign the falling sprite, and the animation should play.
 
Use
Code:
else if
Don't you mean else? And that won't really fix anything, it would logically be the same thing.

Chance is probably correct, you need to make sure your image_speed variable of the object itself is greater than zero in order for the frames to animate.
 
S

Spin Attaxx

Guest
But you have. Setting image_speed to 0 anywhere in that instance's code will affect any sprite you happen to assign, until you change image_speed back to 1. So you've probably set it to 0 somewhere else in the step event for a different sprite, and forgot about it.

So explicitly reset it to 1 when you assign the falling sprite, and the animation should play.
My code looks like this now:
Code:
if (grounded != true)
{
    if (vsp < 0) sprite_index = spr_player_jump;
    if (vsp >= 0)
    {
        sprite_index = spr_player_fall;
        image_speed = 1;
    }
}
And the problem is the same. It switches over to the fall animation, but it's stuck on the first frame.
 
Top