I have some sprites and labels on the Layer. Before removing them they must do some actions (fade out for example). But after that I need to remove them from the layer with using [self removeChild:child cleanup:YES]. For that I create classes AutoCleaningSprite and AutoCleaningLabel which inherit Sprite and Label class and have new method:
- (void) removeFromParent{
CocosNode *parent=self.parent;
[parent removeChild:self cleanup:YES];
}
So for removing this objects after animation I used next actions:
[someAutoCleaningSprite runAction:
[Sequence actions:[FadeOut actionWithDuration:0.5],
[CallFunc actionWithTarget:someAutoCleaningSprite selector:@selector(removeFromParent)],nil]];
Is it correct method? Or may be there is something more simple way for removing CocosNode objects from the parent Object?
And I have another question - is it need to invoke [sprite release]; after [self removeChild:sprite cleanup:YES];?
Thanks..