Cocos2d-x進修筆記之CCLayerColor層的應用實例。本站提示廣大學習愛好者:(Cocos2d-x進修筆記之CCLayerColor層的應用實例)文章只能為提供參考,不一定能成為您想要的結果。以下是Cocos2d-x進修筆記之CCLayerColor層的應用實例正文
CCLayerColor層的應用辦法,寫的具體了一些,和上篇文章根本差不多的(檢查CCLayer的更多引見),只不外此次HelloWorld繼續自CCLayerColor。
bool HelloWorld::init() { bool bRet = false; do { //ccc4這個宏的參數分離為R,G,B,A最初一個是通明度,設置成255就是不通明的,設置成0是通明的 CC_BREAK_IF(!CCLayerColor::initWithColor(ccc4(128,128,128,255))); CCSize size = CCDirector::sharedDirector()->getWinSize(); CCSprite * sprite = CCSprite::create("image1.png"); sprite->setPosition(ccp(100,100)); this->addChild(sprite); //新建一個colorlayer ccColor4B color = ccc4(200,200,0,255); CCLayerColor * layer = CCLayerColor::create(color); //設置layer層的年夜小 layer->setContentSize(CCSizeMake(200,200)); //這一步使layer層的錨點為(0.5,0.5),若不怎樣設置,默許錨點在(0,0)處 layer->ignoreAnchorPointForPosition(false); layer->setPosition(ccp(size.width/2,size.height/2)); this->addChild(layer); bRet = true; } while (0); return bRet; }