Thursday, 21 July 2011

Queue commands which have delays in them

Ok, say you have a label that you want to fade out, and then afterwards you want to remove it from view. You can't just have 2 lines of code, 1 to fade out and the other to remove one after the other, otherwise when xcode executes the code it will remove the label from view before the animation is removed from view. So to queue commands like this you need to use a CCSequence and a function.


id action = [CCSequence actions:[CCFadeOut actionWithDuration:0.5],[CCCallFunc actionWithTarget:self selector:@selector(deleteLabel:)], nil];
[splashLabel runAction:action];

-(void) deleteLabel :(id)sender
{
    CCLabelTTF *temp = (CCLabelTTF*)sender;
    [self removeChild:temp cleanup:YES];
}

No comments:

Post a Comment