2D Toolkit Forum

2D Toolkit => Support => Topic started by: mike2d on July 03, 2012, 05:26:55 pm

Title: Chain of animations
Post by: mike2d 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  ?
Title: Re: Chain of animations
Post by: unikronsoftware 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;
        ...
    }
}
Title: Re: Chain of animations
Post by: mike2d on July 04, 2012, 07:51:02 pm
thanks