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

Instance_change animations problem

S

Stancho

Guest
hello.
So i have my guy standing with his standing animation. then when i press 'T' i want him to attack using the following:
instance_change(obj_player_hit, false);

But when the instance changes, the animation doesn't start from the first frame. It starts from the frame of the previous instance. For example: If i press 'T' when my standing animation is at frame 3, then my 'hit' instance will start it's animation from frame 3 rather than 0.

Hope i managed to explain.
 
S

Stancho

Guest
set image_index to 0 when the instance is changed.
Simon Gust, thank you very much. I have another question if you could answer here (don't want to start multiple threads).

So I have a sprite with 4 images.
Can i use image_index (and if yes, how) to cycle only through the first 2 images or the last 2 images. And if no, then what must i use to cycle through the first 2 images or the last 2 images.

Thank you
 

Simon Gust

Member
It gets a bit complicated.
Code:
if (image_index + image_speed + 2 >= image_number)
{
   image_index = 0;
}
or
Code:
if (image_index + image_speed >= image_number)
{
   image_index = 2;
}
Not sure if this still works in GMS 2.


I suggest using 2 different sprites though.
 
Top