Skip to content
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

Triggering the animateSprite 'play' method in the 'complete' function does not work #12

Open
Gazoo101 opened this issue Mar 31, 2016 · 1 comment

Comments

@Gazoo101
Copy link

Hey - fantastic work on this cool jQuery package.

I'm trying to use it for a neat little project where I'm dynamically switching between some animations. Basically causing a character to pick randomly between a series of animations. It seemed ideal to use the 'complete' function callback to have the animation system automatically switch from one animation to another. Unfortunately, it seems this doesn't work currently.

If I call the animateSprite from within the complete function callback, either directly or via another method the whole animation system stalls. I'm working on a simple workaround using my own timers, but it would be ideal to simply rely on the animation systems own callback functionality.

@Gazoo101
Copy link
Author

Gazoo101 commented Sep 14, 2016

I'm confused, because I got an e-mail from someone asking to explain my workaround but I don't see their message in this thread?!

In anycase, the workaround is pretty straight forward. Since the animateSprite package allows you to specify a playback rate (i.e. FPS), you can calculate when an animation is scheduled to end and pre-maturely call the JavaScript setTimeout function to trigger a function that then changes the animation upon completion. So if the animation ends in 666ms, you just call setTimeout with the same timing to trigger a new animation after that time.

It is a little bit of a hack, given that it's a timer separate from the integrated animation system, but it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant