9.多彩的幕布layer
- CCLayerCorlor
bool CCLayerColor::initWithColor(const ccColor4B & color); bool CCLayerColor::initWithColor(const ccColor4B & color, GLfloat w, GLfloat h); //例子 CCLayerColor::initWithColor(ccc4(255, 255, 255, 255)); CCLayerColor::initWithColor(cc4(255, 255, 255), 100, 100); ignoreAnchorPointForPosition(false);
- CCLayerGradient
bool CCLayerGradient::initWithColor(const ccColor4B & start, const ccColor4B& end); bool CCLayerGradient::initWithColor(const ccColor4B & start,const CCLayerGradient, const CCPoint& v); //例子 CCLayerGradient::initWithColor(ccc4(123, 89, 0, 255), ccc4(0, 255, 255, 255), ccp(10));
代码例子:
1 class T4ColorLayer:public CCLayerGradient 2 { 3 public: 4 static CCScene *scene(); 5 CREATE_FUNC(T4ColorLayer); 6 bool init(); 7 }; 8 9 bool T4ColorLayer::init() 10 { 11 //CCLayerColor::initWithColor(ccc4(255, 255, 255, 255)); 12 CCLayerGradient::initWithColor(ccc4(255, 0, 0, 255), ccc4(0, 0, 255, 255)); 13 return true; 14 } 15
运行效果: