GML Reversing animation on Animation End Event

Hi, I have a sprite with 6 frames. I'm trying to reverse its animation whenever image_index hits 0 or 5.
So to clarify, the sprite's frames should display the following: 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5...

The code I currently have was previously working fine, but now causes the sprite to display indexes 0-5, then flickers between 0 and 5.
What would be a better solution?
Code:
//Create:
image_speed = 1;

//Animation End:
image_speed *= -1;

I have also tried this with the same Create event above, but the sprite doesn't move at all. I'm thinking it's because it's constantly switching between image_speed 1 and -1.
Code:
//Step:
if (floor(image_index) == 5 || floor(image_index) == 0) image_speed *= -1;
 
Might need someone else to confirm, but really, the best way I find is to just add the reverse animation in the sprite itself. I'm reasonably sure GMS is smart enough to notice the sprites in the animation are duplicated, so it won't change anything in regards to texture pages or whatever.
It's also the most simple solution!
 
According to the manual regarding the sprite editor, you can set the sprite to "ping-pong" here. I'm not entirely sure how that affects the built-in variables (image_speed, image_number, etc.), but it should work for your use-case.
It seems like this might only set the sprite to ping pong within the sprite editor preview. But if that's not the case, I can't seem to get it to save as ping-pong.

Might need someone else to confirm, but really, the best way I find is to just add the reverse animation in the sprite itself. I'm reasonably sure GMS is smart enough to notice the sprites in the animation are duplicated, so it won't change anything in regards to texture pages or whatever.
It's also the most simple solution!
This was my original method since it was the easiest! But I was afraid it would muck up the texture pages. I might just go with this solution if it really doesn't add additional baggage.
 
Top