-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for animated sprite not stopping #7211
Conversation
Thanks for this @Owlzy. Can you provide an example of this not work so we can verify? |
Sure. Having made a playground I now see it is specific to autoUpdate = false. In this playground can see that animation plays regardless of calling stop(). If loop is true it will continue looping, or if not looping it will play till the last frame and stop. |
Got it, this example is helpful for context. At first, it seemed a little redundant to add this check, but now I see why because you are enabling I fine with this, but additional, I think it might be nice to add const sprite = new AnimatedSprite();
sprite.autoUpdate = false;
sprite.on('play', () => ticker.add(sprite.update, sprite) });
sprite.on('stop', () => ticker.remove(sprite.update, sprite) }); Play and stop would allow you to remove from the ticker or event loop and remove that call all together, which means you wouldn't need to defensively add the check in update. I think there's value in both, just a thought. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please fix the linting? Otherwise, I'm fine with this.
Sorry thought I fixed that already. Should be fixed in the latest commit. |
Codecov Report
@@ Coverage Diff @@
## dev #7211 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 17 17
Lines 699 699
=========================================
Hits 699 699 Continue to review full report at Codecov.
|
Thank you @Owlzy 🎉 |
Description of change
Fixes issue where animated sprite continues to play even when
_playing = false
Pre-Merge Checklist
npm run lint
)