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

Sprite sheet animation reset

T

Turrican

Guest
Hi, this is my first post, I hope I have not made mistakes with the regulation of the forum.
I made an animation that makes the character start to walk (from a stand position) and walk. I want that animation start from the frame 0 for the first animation, than loop from the frame n. 18. (0-18 is the start walk, 18-end is the walking loop). So I made this:
Code:
//Animation
if (vsp == 0)
{
    sprite_index = Spr_Breathe;
}
else
{
        sprite_index = Spr_WalkU;
        if (image_index==image_number -1)
        {
        image_index = 18;
        }
}
And it works except for the fact that if i stop the movement (WalkU) and restart, the walking animation start from the last frame of the previous walking, how can I set that the animation start from frame 0?
Thanks
 
L

Lander

Guest
You have to set the image_index back to 0. To do that I would:
if (vsp == 0)
{
sprite_index = spr_breathe;
image_index = 0;
}
else
{
sprite_index = spr_walkU
if (image_index == image_nmber - 1)
{
image_index = 18;
}
}

I think this well work.
If it doesn't I am sorry
 
T

Turrican

Guest
I found the answer, use the Not operator "!=" and image_index = -1, first to call the new sprite:
Code:
if (vsp= 0)
{ sprite_index = spr_breathe;}
else
{
    if (sprite_index != spr_Walku) image_index = -1;
    sprite_index = spr_Walku;
    if (image_index == image_number -1)
        {
        image_index = 18;
        }
}
 
Top