[SOLVED] Events Panel Skips Animation

I’m new here so I’m not an expert on this. In my game I have a sprite with 32 animations. I want the sprite to move to the next animation when a button is clicked. I want to be able to loop back to the first animation with the same button once all the animations have been clicked through (a loop effect basically).

Here is my current setup:

The issue with this setup is that instead of going back to the first after going through all animations, the events panel will skip the last animation to move over to the first. What am I doing wrong here?

I’m assuming “Seahawks” is the final animation of the Banner object. So think about what’s happening - the first set of actions set the animation to the one following. When Banner is at the second to last animation, that event increases it to the last animation.

Then in the subevent, a check is made whether Banner is on the last animation, and set it to the first one if so. Therefore, the last animation is never used.

A way around this is to use the mod function. This returns the remainder when a number is divided by another.

You have 32 animations. So you can set the Banner animation with:

image

That’s all there is to it, no need for the subevent. That action in the screen snip increments the Banner animation number by 1 and the mod returns the remainder when it’s divided by 32. So when it reached 32, the Banner animation is set back to 0. One line, not need for the subevent.

Also, you didn’t need to that second “RightButton is clicked” condition in the subevent. That was taken care of in the parent event. You wouldn’t have made it to the subevent if the right button wasn’t clicked.

1 Like

That works. Thanks for the help.