cykod / Quintus

HTML5 Game Engine
http://html5quintus.com
GNU General Public License v2.0
1.41k stars 401 forks source link

Add callback for playing animations #135

Open vincentjames501 opened 10 years ago

vincentjames501 commented 10 years ago

If on a sprite I call this.play('whatEverAnimation'), it would be nice to pass a possible callback as to know when the animation ended. I see that on a Tween it's possible to do this, but it would be nice to do this from the play function. I'm not an expert in Quintus, so if there is a better way to accomplish this please let me know!.

dy-dx commented 10 years ago

I think you may be able to use the animEnd events: https://github.com/cykod/Quintus/blob/master/lib/quintus_anim.js#L51-L52

I haven't tried this myself however.

cykod commented 10 years ago

Animations trigger animEnd.animation-name events when they finish as well allow a custom event by passing in a trigger property - do either of those work for you?