Toggle Animations

0 favourites
  • 6 posts
From the Asset Store
Toggles Dials Switches and Alerts ! A foundational sound grouping of Analog type switches and Steampunk effects
  • Hey all,

    I'm having some trouble toggling an animation. The first time you click on something, I want it to go to frame 1. The second time, I would like it to go back to frame 0. The third, back to frame 1. This is the way I have it and its not correct.

    Touching - Object        - Wait 1 second

    Animation Frame = 0       - Set animation Frame to 1

    Else

    Touching - Object        - Wait 1 second

    Animation Frame = 1       - Set animation Frame to 0

    Unfortunately, the "else" does not stop the program from carrying out those actions. I will click the object once and it does not appear to animate.

  • Those events are trigger each other, so you'll either get unpredictable, or simply broken results.

    But here's an easy way to toggle between two frames: On touch -> set frame to 1-currentframe

  • Thanks for your response Geometrix, it certainly simplifies the code. However, I am still having trouble... it still reacts the same way- unpredictably and broken. 50% of the time it works perfectly, the other 50% it just blinks 5 times and stays on the same frame.

  • Thanks for your response Geometrix, it certainly simplifies the code. However, I am still having trouble... it still reacts the same way- unpredictably and broken. 50% of the time it works perfectly, the other 50% it just blinks 5 times and stays on the same frame.

    Make sure you have the animation speed set to zero, otherwise once it gets to the specified frame it will attempt to loop.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I had animation speed set to 0 - I finally figured out the problem... the "Touching object" event is broken - you need to couple it with "At any Touch end"

    Event:

    Touching Object

    Condition:

    At any touch end

    Action: x

    The animation frame math from Geometrix was on point as well.. thanks all

  • Is Touching Object isn't broken, you were just using it wrong. Actions like that are activated every tick that they're true, whereas actions like On Touch End (and On Touched Object - which is probably what you should be using) are just triggered a single time - upon activation.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)