开发者

When I fade out a label in cocos2d, it can't fade back in

I have a function to fade in a message, then fade out.

This works once, but when I call the function again, nothing appears.

[gameBonusLabel runAction:[CCFadeTo a开发者_运维技巧ctionWithDuration:0.1 opacity:1.0f]];

[gameBonusLabel setString:messagetext];
gameBonusLabel.position = ccp(240+(gameBonusLabel.contentSize.width / 2),260);


[gameBonusLabel runAction:[CCFadeTo actionWithDuration:1.5f opacity:0.0f]];

Is there anything else I need to do, I'm unsure why the fade in doesn't work the second time.

For reference, if I comment out the fade in/fade out, this works multiple times and updates the text + position correctly.


The opacity is a byte value. Max is 0xFF or, as used in Cocos2D, 255. Your range is from 0 to 255.

It is possible you may run into timing problems too. The processor will run through that code very quickly and you are likely to have the second action start before the first one is complete, which can sometimes cause undesirable things. Try using two separate labels or CCSequence.


The level of opacity has a value of 255 =)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜