maniclorn
maniclorn

Reputation: 1089

COCOS2D disappear sprite after animation

I am designing a quiz. Want to animate wrong answer sprite for 2-3 seconds. then it should disappear automatically. How can I do that?

Upvotes: 0

Views: 1017

Answers (1)

George
George

Reputation: 4029

CCFadeOut *fade = [CCFadeOut actionWithDuration:3];  //this will make it fade
CCCallFuncN *remove = [CCCallFuncN actionWithTarget:self selector:@selector(removeSprite:)];
CCSequence *seq = [CCSequence actions: fade, remove, nil];
[mySprite runAction:seq];

This is the method called by the CCCallFuncN object we alloc'ed above.

-(void) removeSprite:(id)sender 
{
[self removeChild:sender cleanup:YES];
}

Hope this helps.Cheers!

Upvotes: 3

Related Questions