2D Toolkit Forum

2D Toolkit => Support => Topic started by: tyrannosaur_jet on November 28, 2012, 06:33:50 pm

Title: Sequencing Sprite Animations
Post by: tyrannosaur_jet on November 28, 2012, 06:33:50 pm
Is there a way to sequence sprite animations, in much the same way as you would sequence different tweens in HOTween? I'm coming from Cocos2D, where there's a way to define a sequence where a sprite would play animation A and wait for it to finish before playing animation B (or delaying, or calling a method, tweening, etc.) I mentioned HOTween because you've suggested it before for other sprite properties on this forum, and because it has that same sort of sequencing built in; if there's a way to get tk2d sprite animations integrated with that, that would be great.
Title: Re: Sequencing Sprite Animations
Post by: unikronsoftware on November 28, 2012, 11:36:09 pm
You could do it using the animation complete delegate...

Check the tk2dDemoAnimController.cs,
Code: [Select]
animSprite.animationCompleteDelegate = delegate(tk2dAnimatedSprite sprite, int clipId)
{
animSprite.Play("demo_pingpong");
animSprite.animationCompleteDelegate = null;
};
That plays "demo_once", and as soon as it is complete it plays "demo_pingpong". Is that the sort of thing you're looking for?