How to code a Button cycling Animations?


  • Posts: 6
I was stuck on making an event work, so starting from new. Just an empty scene, and 2 actors. One is a button, one is to be a piece of background that is 7 different objects (Images) saved as 7 different animations. What do i put into the event tab, so that the button with each mouse-click on it will cycle the 7 Animations of the other actor in the scene. 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4 ...and so on (Looping), i searched around and can find answers to similar things, but not this specifically. Thanks


  • *
  • Posts: 2704
One number attribute hidden, and another non-hidden.
If mouse was pressed, increment number by one.
-If your number attribute is greater than a preset value (another non-hidden number attribute), set your number to 0.
In an Updating event, set the animation to that number (as text). You set the non-hidden attribute to the number of animations you want to loop through.

This way, so long as your animations are named 1, 2, 3 etc, they will match the number attribute.
My Stencyl resources are available here:
Cutscenes, RPG Elements, Particles, Map System and many more.


  • Posts: 6
Thanks. I had to make some changes, like using keys instead of mouse clicks. But this pointed me in the right direction, it's working now