Hi!
As you might know, the “ended” phase of a “sprite” event is fired the moment that the last frame is shown.
Most likely this is intended to be, but in my usecase it’s pretty annoying.
For example when I’m spawning an explosion somewhere, I would like to listen to the “ended” phase to detect when I should remove it from the screen, using the “ended” phase here would cause the last frame of the explosion animation to not be shown…
Currently I can think of 3 solutions for a possible work around
- Writing a wrapper around display.newSprite that handles the “frames” or “start&count” params to add an extra frame (eg. frames = {1,2,3,4} will become {1,2,3,4,4}
- Adding a timer.performWithDelay with the time of 1 frame before I handle the “ended” phase
- Supplying the extra frame myself (see example solution 1), but this won’t let me do it with start&count params
How would you guys solve this problem?