2D Toolkit Forum
2D Toolkit => Support => Topic started by: ItsMeAlan on March 03, 2013, 04:52:11 am
-
Is there a way to do determine which number frame is currently playing in an animated sprite? I don't see anything like that here (http://unikronsoftware.com/2dtoolkit/doc/html/classtk2d_animated_sprite.html).
Thanks!
EDIT: Kind of a roundabout way of finding it but I got it working with this:
var currentFrame:int = ((animate.ClipTimeSeconds * animate.CurrentClip.fps) % animate.CurrentClip.frames.length);
-
That roundabout way only works with looped clips, but yeah that's probably the best way to get to it.
Is there any specific reason you need to get the clip rather than the clip time? I can probably add some helper functions if there is a good enough reason. There already are some editor functions for these, but with the other wrap types, its not that straightforward at all.
-
I'm trying to do some complex, smoothly-transitioning animation. I have a "running" animation, an "idle" animation, and a transitional "runningToIdle" animation. I had to make it so the animatedSprite would only start playing "runningToIdle" when "running" was on its final frame. That is unless of course the character was in the process of running, in which case "running" needed to loop.
EDIT: Just to clarify, I was able to get this to work fine with the code I posted above
-
Yup the code above will work fine for looped or one shot clips.