我试图弄清楚如何将图层及其子级淡化为给定的不透明度。这就是我正在做的事情。
- (id)init
{
if( (self=[super initWithColor:ccc4(0, 0, 255, 255)] )) {
CCSprite *background = [CCSprite spriteWithFile:@"LevelsBackGround.png"];
background.position = ccp([UIScreen mainScreen].bounds.size.height * .5f ,160);
[self addChild:background];
CCSprite *text = [CCSprite spriteWithFile:@"SwipeText.png"];
text.position = ccp([UIScreen mainScreen].bounds.size.height *.5, 17);
[self addChild:text];
sceneText = [CCLabelTTF labelWithString:@"Yard" fontName:@"Baskerville-Bold" fontSize:20];
sceneText.position = ccp([UIScreen mainScreen].bounds.size.height *.5, 300);
sceneText.color = ccc3(172, 169, 164);
[self addChild:sceneText];
[self performSelector:@selector(LaunchLevel:) withObject:nil afterDelay:2.f];
}
- (void ) LaunchLevel: (id) sender {
[self runAction:[CCFadeTo actionWithDuration:.5 opacity:127]];
}
但这似乎没有任何作用。如果我删除背景精灵以查看我设置图层的蓝色然后构建它,那么蓝色背景会完全褪色。所以我的问题是,为什么淡出所有图层子级不起作用?