I have created a sprite and inside that sprite I have a label like this.
CCLabelTTF *myLabel = [CCLabelTTF
labelWithString:text
dimensions:CGSizeMake(mySpriteWidth*0.9, mySpriteHeight*0.9)
alignment:UITextAlignmentCenter
fontName:@"Helvetica Neue" fontSize:20.0f];
[myLabel setPosition: CGPointMake((mySpriteWidth/2.0f),(mySpriteHeight/2.0f))];
[mySprite addChild: myLabel];
as you see the label is a child of mySprite.
Then I fade out the sprite using this action
id fadeOut = [CCFadeOut actionWithDuration:0.4];
The sprite fades out correctly, but the label continues there, arrogantly looking at me…
is this a bug or I am missing something? Thanks
the code I use to do the fade is this:
CCSequence *sequence =[CCSequence actions:
fadeIn,
[CCDelayTime actionWithDuration:2.5],
fadeOut,
nil];
[mySprite runAction:sequence];
// [myLabel runAction:sequence];
adding the action to the label, makes it vanish, but then the sprite stays on the screen… 🙁
You should be removing the sprite after the fade is complete. when it is removed if you are not going to use it again. or toggle its visibility if you will.
I’m not 100% sure if fade out will echo to its inner views. it affects objects that inherit from CCRGBAProtocol
CCFadeout reference
this should get you around your problem at least. if u want the label to fade out also you can access the label using getChildByTag to give it a fade effect also.
But you will need to create a new fade effect, the way Actions are implemented in cocos is that 2 objects can run the same action, the latter will.