blaiprat / jquery.animateSprite

Animating sprites using jQuery made easy
http://blaiprat.github.io/jquery.animateSprite/
MIT License
122 stars 39 forks source link

Get the current frame #9

Open mmind-hub opened 9 years ago

mmind-hub commented 9 years ago

Hi, great plugin ! I need play animations dynamically, for rollovers/rollout animations. The problem is when i rollout i don't want my rollout animation to play from the start but from the current frame for a nice animation. With the current frame i could edit the rollout animation.

For exemple to be clear : var spriteSettings = { fps: currentFps, loop: false, autoplay: false, animations: { walkLeft: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,18,19,20,21,22,23,24], walkRight: [24,23,22,21,20,19,18,17,16,15, 14, 13, 12, 11, 10, 9, 8,7,6,5,4,3,2,1,0] } };

If i play the walkRight animation before walkLeft is finished, let's say at frame 17, i don't want walkRight to play from 24 but from the frame 17.

Any idea how to do that ? Thanks again !

blaiprat commented 9 years ago

To do what you want you need to know the current animation frame, but with the current version of the plugin there's no way to read the value from outside the plugin.

I'll try to release a new version so you'll be able to retrieve the animation and have some logic to handle your transition exactly how you want it.

mmind-hub commented 9 years ago

Thank's !

blaiprat commented 9 years ago

Even if it's not ready for production yet, you might want to look at this new version of animatesprite. It's vanilla javascript but it should play nice with jQuery objects:

https://github.com/blaiprat/animateSprite

Hopefully this weekend I'll have some time to prepare a proper release (0.1.0).