cocos2d-x CC_SYNTHESIZE_READONLY


//定義一個只讀屬性Label,在類定義中可以使用this->getLabel來訪問
     CC_SYNTHESIZE_READONLY(cocos2d::CCLabelTTF*,_label,Label);
 
CC_SYNTHESIZE_READONLY(varType, varName, funName)聲明一個成員變量以及getfunName函數,沒有set函數。getfunName已經實現,其實現就是返回這個值。
 
this ->_layer = GameOverLayer::node();
this ->_layer->retain();         
this ->addChild(_layer);
 
 
bool GameOverLayer::init()
{
     if (CCLayerColor::initWithColor(ccc4(255,255,255,255)))
     {
         CCSize winSize = CCDirector::sharedDirector()->getWinSize();
         this ->_label = CCLabelTTF::labelWithString( "" , "Artial" ,32);
         this ->_label->retain();
         this ->_label->setColor(ccc3(0,0,0));
         this ->_label->setPosition(ccp(winSize.width/2,winSize.height/2));
         this ->addChild( this ->_label);
 
         this ->runAction(CCSequence::actions(CCDelayTime::actionWithDuration(3),
                                         CCCallFunc::actionWithTarget( this ,
                                         callfunc_selector(GameOverLayer::gameOverDone)),NULL));
         return true ;
     }
     else
     {
         return false ;  
     }
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM