2D Toolkit Forum

2D Toolkit => Support => Topic started by: LBandy on June 29, 2012, 03:03:11 pm

Title: tk2dAnimatedSprite.getFrame() function
Post by: LBandy on June 29, 2012, 03:03:11 pm
Hi there!

Thank you very much for this great plugin. However, I would like to know if there is a possibility to get the frame id which is currently playing? We need to synchronize multiple animation together, and knowing the actual frame in the animation is essential for this. I hope there would be a simple workaround for this.

Thank you for your help!
Title: Re: tk2dAnimatedSprite.getFrame() function
Post by: mike2d on June 29, 2012, 06:25:00 pm
yup, i'd be interested in this one too :)
Title: Re: tk2dAnimatedSprite.getFrame() function
Post by: unikronsoftware on June 29, 2012, 08:55:11 pm
frame = (int)(anim.ClipTimeSeconds * anim.CurrentClip.fps);

That should do it.
Title: Re: tk2dAnimatedSprite.getFrame() function
Post by: mike2d on July 03, 2012, 07:59:06 pm
 ;D

nice, i'll test that.
Title: Re: tk2dAnimatedSprite.getFrame() function
Post by: LBandy on July 04, 2012, 12:37:32 pm
frame = (int)(anim.ClipTimeSeconds * anim.CurrentClip.fps);

That should do it.

Thanks for the advice. Is there a way to be able to sync the animation in a more precise way? Because if I use this solution, at a given 24 fps framerate the delay is noticable.
Title: Re: tk2dAnimatedSprite.getFrame() function
Post by: unikronsoftware on July 04, 2012, 12:54:06 pm
If you want to sync animations, you'll be better off syncing clipTimes, as frameIds are rounded down integers.

Get the ClipTimeSeconds from the source sprite, and then when calling Play on the second clip, use Play(id, otherClipTimeSeconds);
Title: Re: tk2dAnimatedSprite.getFrame() function
Post by: DannyB on September 10, 2012, 05:24:03 pm
Thanks for this. The time sync works perffectly.