CCLayerColor 用法
在cocos2d-iphone 1.0版本以后
将CCColorLayer改为了CCLayerColor
两种方法更换背景
方法一
CCLayerColor *layerColor = [CCLayerColor layerWithColor:ccc4(255, 0, 255, 255)];
[self addChild:layerColor z:0];
方法二
[self addChild:layerColor z:0];
方法二
新建自己的类
#import <Foundation/Foundation.h>
#import "cocos2d.h"
@interface cccolor : CCLayerColor {
}
#import "cocos2d.h"
@interface cccolor : CCLayerColor {
}
@end
@implementation cccolor
-(id)init
{
if( (self=[super initWithColor:ccc4(255,255,255,255)] ))
{
}
return self;
}
@end
-(id)init
{
if( (self=[super initWithColor:ccc4(255,255,255,255)] ))
{
}
return self;
}
@end
用法
cccolor *colorlayer = [cccolor node];
[self addChild:colorlayer];
[self addChild:colorlayer];