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

Windows Sprite_index (ping-pong) how to do?

my Animation End :
GML:
if sprite_index=spSaraAttack {sprite_index=spSaraStay}
if sprite_index=spSaraStay {sprite_index=spSaraStayAnim}
 
I need to spSaraAttack sprite which from 13 frames was played from 1-13 and back from 13-1 and the same thing is necessary for spSaraStayAnim which is 7 frames.
since the ping-pong function does not work in GMS2, I want to do this through codes!
should be like this:

spSaraStayAnim
(1-2-3-4-5-6-7-6-5-4-3-2-1)

spSaraAttack
1-2-3-4-5-6-7-8-9-10-11-12-13-12-11-10-9-8-7-6-5-4-3-2-1

I tried different things but I lack experience, I use GMS2 for only almost 2 months ((
 

Felbar

Member
//Ping Pong an animation
if (image_speed > 0) {
image_index = image_number - 1;
image_speed = -1;
}
else {
image_index = 0;
image_speed = 1;
}

this works for me
in Animation end event
 

chamaeleon

Member
I need to spSaraAttack sprite which from 13 frames was played from 1-13 and back from 13-1 and the same thing is necessary for spSaraStayAnim which is 7 frames.
since the ping-pong function does not work in GMS2, I want to do this through codes!
should be like this:

spSaraStayAnim
(1-2-3-4-5-6-7-6-5-4-3-2-1)

spSaraAttack
1-2-3-4-5-6-7-8-9-10-11-12-13-12-11-10-9-8-7-6-5-4-3-2-1

I tried different things but I lack experience, I use GMS2 for only almost 2 months ((
You have not clarified if you use those two sprites for two different objects/instances, or if you somehow want to change between them for one instance.
 

chamaeleon

Member
The please clarify what Animation End means, with respect to wanting to swap sprites. If you're using Animation End to swap sprite, when would you expect to do the reverse animation? You need some other condition to say, "I'm not going to switch direction, I'm swapping sprite instead". What is the criteria for that?
 
Top