Toggle Animations

Get help using Construct 2

Post » Tue Jul 02, 2013 5:15 pm

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.
B
9
S
2
G
2
Posts: 47
Reputation: 1,822

Post » Tue Jul 02, 2013 5:45 pm

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
B
57
S
15
G
11
Posts: 912
Reputation: 12,606

Post » Tue Jul 02, 2013 6:23 pm

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.
B
9
S
2
G
2
Posts: 47
Reputation: 1,822

Post » Tue Jul 02, 2013 6:32 pm

[QUOTE=ClocksTNW] 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.[/QUOTE]

Make sure you have the animation speed set to zero, otherwise once it gets to the specified frame it will attempt to loop.
B
8
S
2
Posts: 63
Reputation: 1,223

Post » Tue Jul 02, 2013 7:32 pm

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
B
9
S
2
G
2
Posts: 47
Reputation: 1,822

Post » Tue Jul 02, 2013 8:18 pm

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.
B
57
S
15
G
11
Posts: 912
Reputation: 12,606


Return to How do I....?

Who is online

Users browsing this forum: blissfulwizard, DevinMurray, Google [Bot] and 15 guests