On Animation Finished triggers while last frame still plays

Bugs will be moved here once resolved.

Post » Thu Oct 01, 2015 4:39 am

Problem Description
On Animation Finished trigger fires while last frame plays instead of when it finishes.

Attach a Capx

Description of Capx
This project is a simplified version of a concept I'm using for climbing ladders or vaulting over walls in my game, simplified to two events. When the movement is triggered (in this case by pressing Space) the game triggers the animation "Move". The second line is "On Animation "Move" Finished" which then moves the sprite to the position that the animation ended up, in the game that would be wherever the character climbed to. However, the event seems to be triggering -while- the last frame plays and causes animations to flicker between states.

Steps to Reproduce Bug
  • Step 1: Trigger an animation "Example"
  • Step 2: Create a "On Animation "Example" Finished" trigger that moves the sprite.

Observed Result
The sprite moves into the new location before the animation finishes and causes the sprite to appear in the wrong location until it sets the animation to default.

Expected Result
The "Move" animation would play in its entirety before triggering the event, resulting in a sprite that appears to have seamlessly moved.

Alternate Repro
  • Step 1: Create a sprite with two animations, "Green" and "Red".
  • Step 2: Create event: On keypress: set sprite animation to "Red" and set sprite invisible.
  • Step 3: Create event: On animation "Red" finished: set sprite animation to "Green" and set sprite visible.

Observed Result
The sprite will remain green, pressing control will make the object invisible but then it will flicker red for a frame after becoming visible and before turning green again.

Expected Result
The sprite would only show green, the red frames would never be visible.

Affected Browsers
  • Chrome: YES
  • FireFox: Untested
  • Internet Explorer: YES

Operating System and Service Pack
Windows 7 Home Premium SP1

Construct 2 Version ID

This alternate example has less practical use but is an easier example to show the events playing before the animation has finished.

I've tried working around this by ending my animation with a blank frame but this just causes the character to flash invisible.
Posts: 6
Reputation: 744

Post » Thu Oct 15, 2015 2:13 pm

Closing as won't fix: by design, changing the animation inside an animation trigger (in this case, "On animation finished") causes the animation change to be postponed to the next tick. Unfortunately I can't remember why this was originally done, but it was in response to other bug reports. This means for one tick it renders the last animation frame at the offset position. This is not normally a problem, and only seems to be because you're unusually using the animation system as a way to move objects. You don't need to use animations for that: you could just have a cropped single frame for the "move" animation and change its position with events only instead of wastefully using an animation to simulate movement (see remember not to waste your memory). Alternatively as a workaround add "Wait 0 seconds" as the first action in "On animation finished", which postpones both the positioning and animation change to the next tick, where they occur simultaneously.
Scirra Founder
Posts: 24,888
Reputation: 198,582

Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 2 guests