cocos2d Tip: Opacity, CCFadeOut, & CCFadeTo
August 13th, 2010
When using opacity and want to fade out, use fade to!
Using fade out it will reset the opacity and then fade it out… so a fade to opacity 0, will prevent the reset.
1 2 3 4 5 6 7 8 9 |
// GIVEN CCSprite *sprite = [CCSprite spriteWithFile:@"sprite"]; sprite.opacity = 150; // DO [sprite runAction:[CCFadeTo actionWithDuration:1.0f opacity:0]]; // DON'T [sprite runAction:[CCFadeOut actionWithDuration:1.0f]]; |
