How do I wait for a framenumber before changing animations

Get help using Construct 2

Post » Wed Apr 20, 2016 7:19 pm

I am looking to wait until an animation runs through it's entire frame cycle before changing to another animation.

The first animation is on a loop and has 18 frames in it's animation.
At any point the second animation may trigger, and I need the event to wait until the first animation gets to 18 before it sets the new animation.

Is this possible?
B
7
S
1
Posts: 18
Reputation: 423

Post » Wed Apr 20, 2016 7:25 pm

You can compare the frame number and there is also a "on animate completed" condition. Either of them could be used.
B
94
S
33
G
113
Posts: 5,354
Reputation: 73,269

Post » Wed Apr 20, 2016 7:43 pm

Can you show me a quick example of the loop you would do to achieve this?
I am thinking when animation change is triggered, wait until frame = 18 then set new animation,
I am uncertain how to do this loop in construct 2

Also when looking through events I was unable to find the on animation complete in the list?
B
7
S
1
Posts: 18
Reputation: 423

Post » Wed Apr 20, 2016 8:14 pm

What about if you give the sprite an instance variable (text) and call it something like newAnimation. Then in events:

- when you want to trigger animation 2, ie a shooting animation: set sprite.newAnimation to "Shooting"
- first animation frame = 18 & sprite.newAnimation != "": set animation to sprite.newAnimation, set sprite.newAnimation to ""

Basically every time it gets to frame 18 in animation 1 it checks to see if you've put the name of another animation into the newAnimation variable - if you have, it plays the new one and blanks the variable, otherwise, nothing happens and it keeps playing animation 1.
Image



Coming soon on Steam!
B
16
S
9
G
3
Posts: 209
Reputation: 3,476

Post » Wed Apr 20, 2016 8:35 pm

Thanks mikehive, worked a charm ;)
B
7
S
1
Posts: 18
Reputation: 423


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 5 guests