我正在使用UIKit和创建一个 iPhone 应用程序cocos2d。现在,在我的一个中ViewControllers,我添加了一个HelloWorldLayer作为子视图。已成功添加。
现在这个图层被添加了一个黑色的背景颜色。我希望它的背景颜色是clearColor,准确地说,我希望它是透明的,以便我可以查看我的 ViewController 中的内容,除了HelloWorldLayer.
我知道如何更改CCLayer背景颜色。我正在使用ccc4(r, g, b, a)它。
这是我的代码:
-(id) init
{
// always call "super" init
// Apple recommends to re-assign "self" with the "super's" return value
if( (self=[super initWithColor:ccc4(0, 0, 0, 128)]) ) {
CGSize windowSize = [[CCDirector sharedDirector] winSize];
CCSprite *imgRoof;
imgRoof = [CCSprite spriteWithFile:@"Tops.png"];
imgRoof.position = ccp(windowSize.width/2,windowSize.height/2);
[self addChild:imgRoof];
CCAction* action = [CCBlink actionWithDuration:20 blinks:20];
[imgRoof runAction:action];
}
return self;
}
我只想知道 for 的颜色clearColor代码ccc4()。任何人都可以帮助我,我真的被困住了。
非常感谢提前!!!