Hello
Guest
Home
Help
Search
Login
Register
2D Toolkit Forum
»
2D Toolkit
»
Support
»
tk2dAnimatedSprite.getFrame() function
« previous
next »
Print
Pages: [
1
]
Author
Topic: tk2dAnimatedSprite.getFrame() function (Read 8193 times)
LBandy
Newbie
Posts: 2
tk2dAnimatedSprite.getFrame() function
«
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!
Logged
mike2d
2D Toolkit
Jr. Member
Posts: 63
Re: tk2dAnimatedSprite.getFrame() function
«
Reply #1 on:
June 29, 2012, 06:25:00 pm »
yup, i'd be interested in this one too
Logged
unikronsoftware
Administrator
Hero Member
Posts: 9709
Re: tk2dAnimatedSprite.getFrame() function
«
Reply #2 on:
June 29, 2012, 08:55:11 pm »
frame = (int)(anim.ClipTimeSeconds * anim.CurrentClip.fps);
That should do it.
Logged
mike2d
2D Toolkit
Jr. Member
Posts: 63
Re: tk2dAnimatedSprite.getFrame() function
«
Reply #3 on:
July 03, 2012, 07:59:06 pm »
nice, i'll test that.
Logged
LBandy
Newbie
Posts: 2
Re: tk2dAnimatedSprite.getFrame() function
«
Reply #4 on:
July 04, 2012, 12:37:32 pm »
Quote from: unikron on June 29, 2012, 08:55:11 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.
Logged
unikronsoftware
Administrator
Hero Member
Posts: 9709
Re: tk2dAnimatedSprite.getFrame() function
«
Reply #5 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);
Logged
DannyB
2D Toolkit
Hero Member
Posts: 609
Re: tk2dAnimatedSprite.getFrame() function
«
Reply #6 on:
September 10, 2012, 05:24:03 pm »
Thanks for this. The time sync works perffectly.
Logged
Developer of
Chicks Ahead
and
Mahjong Monsters
Print
Pages: [
1
]
« previous
next »
2D Toolkit Forum
»
2D Toolkit
»
Support
»
tk2dAnimatedSprite.getFrame() function