Hello Guest

Author Topic: Chain of animations  (Read 5650 times)

mike2d

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 63
    • View Profile
Chain of animations
« on: July 03, 2012, 05:26:55 pm »
hi,

i'd like to play an animation automatically when a previous one is finished ?

i've seen AnimationCompleteDelegate and Trigger options in the SpriteAnimation Inspector so what are they used for and what's the best way to accomplish what i explained above  ?
« Last Edit: July 03, 2012, 06:40:56 pm by mike2d »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Chain of animations
« Reply #1 on: July 04, 2012, 09:58:12 am »
The easiest way to do this is to hook up an AnimationCompleteDelegate and automatically call Play() from within the delegate. demo "5 - animation" shows how you can hook up an animation event delegate - the animationCompleteDelegate is very similar -

Code: [Select]
animSprite.animationCompleteDelegate = AnimationComplete;

void AnimationComplete(tk2dAnimatedSprite sprite, int clipId)
{
    switch (clipId)
    {
        case 0: sprite.Play("NextClip"); break;
        ...
    }
}

mike2d

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 63
    • View Profile
Re: Chain of animations
« Reply #2 on: July 04, 2012, 07:51:02 pm »
thanks