Hello Guest

Author Topic: Play animation by frame ?  (Read 4118 times)

chansey

  • Newbie
  • *
  • Posts: 2
    • View Profile
Play animation by frame ?
« on: July 17, 2014, 09:43:11 am »
Hi,

I'm a newbie for 2dtoolkit.

Thanks for this awesome tool. :)

However, I have a question:

Is there any way to play animation by frame safely?  (eg: some scripts in tk2d package?)

My requirement is :

//called by simulation framework
void OnStateChanged(var state)
{
    if(state==States.Walk)
    {
        tk2dAnimator.SetClip("Walk", true); //"true" means need reset frame
    }
    //....
}

//called by simulation framework
void OnStateUpdate ()
{
    tk2dAnimator.NextFrame(); //every call NextFrame will show corresponding sprite by frame sequence.
}

my expectation is the animator synchronous with simulation update.

Very thanks.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Play animation by frame ?
« Reply #1 on: July 18, 2014, 02:38:16 pm »
Hi there isn't a way to do this, but you do have all the data you need there. The tk2dSpriteAnimationClip contains a list of sprite collections and sprite Ids per frame, which you can just assign to the sprite. Eg. if you have the tk2dSpriteAnimator disabled, you can call Play and then handle the stepping yourself with CurrentClip

chansey

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Play animation by frame ?
« Reply #2 on: July 20, 2014, 02:54:08 pm »
Thanks :)