Hello Guest

Author Topic: Determine which # frame is currently playing  (Read 4280 times)

ItsMeAlan

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 22
    • View Profile
Determine which # frame is currently playing
« 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.

Thanks!

EDIT: Kind of a roundabout way of finding it but I got it working with this:

Code: [Select]
var currentFrame:int = ((animate.ClipTimeSeconds * animate.CurrentClip.fps) % animate.CurrentClip.frames.length);
« Last Edit: March 03, 2013, 05:22:19 am by ItsMeAlan »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Determine which # frame is currently playing
« Reply #1 on: March 03, 2013, 09:29:23 am »
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.

ItsMeAlan

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Determine which # frame is currently playing
« Reply #2 on: March 09, 2013, 12:25:44 am »
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
« Last Edit: March 09, 2013, 12:29:39 am by ItsMeAlan »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Determine which # frame is currently playing
« Reply #3 on: March 09, 2013, 10:36:56 am »
Yup the code above will work fine for looped or one shot clips.