Cocos2d-x UI開發(fā)之CCControlSwitch控件類使用實例
更新時間:2014年09月11日 10:37:10 作者:皂莢花
這篇文章主要介紹了Cocos2d-x UI開發(fā)之CCControlSwitch控件類使用實例,本文代碼中含大量注釋講解了CCControlSwitch控件類的使用,需要的朋友可以參考下
CCControlSwitch是開關按鈕,關于控件使用時的一些配置,請參見文章:UI開發(fā)之控件類-CCControlButton。以下的演示中出現(xiàn)的key和value代表什么意思,知道的人說一聲。
bool HelloWorld::init() { bool bRet = false; do { CC_BREAK_IF(! CCLayer::init()); //參數(shù)就不說了,看一下你的資源文件就明白了 CCControlSwitch * controlSwitch = CCControlSwitch::create( CCSprite::create("extensions/switch-mask.png"), CCSprite::create("extensions/switch-on.png"), CCSprite::create("extensions/switch-off.png"), CCSprite::create("extensions/switch-thumb.png"), CCLabelTTF::create("On", "Arial-BoldMT", 16), CCLabelTTF::create("Off", "Arial-BoldMT", 16)); //設置位置 controlSwitch->setPosition(ccp(240,160)); //這個函數(shù)對應初始時,開關的狀態(tài)是開還是關。 controlSwitch->setOn(true); //這個函數(shù)對應開關能否使用。 controlSwitch->setEnabled(true); //添加事件監(jiān)聽 controlSwitch->addTargetWithActionForControlEvents(this,cccontrol_selector(HelloWorld::valueChanged), CCControlEventValueChanged); this->addChild(controlSwitch); bRet = true; } while (0); return bRet; } void HelloWorld::valueChanged(CCObject * pSender,CCControlEvent controlEvent) { CCControlSwitch * controlSwitch = (CCControlSwitch *)pSender; CCLog("click"); }
相關文章
C語言驅(qū)動開發(fā)之內(nèi)核通過PEB獲取進程參數(shù)
PEB結構(Process Envirorment Block Structure)其中文名是進程環(huán)境塊信息。本文將通過PEB實現(xiàn)獲取進程參數(shù),感興趣的小伙伴可以了解一下2022-10-10結構體類型數(shù)據(jù)作為函數(shù)參數(shù)(三種方法)
將一個結構體中變量中的數(shù)據(jù)傳遞給另一個函數(shù),有以下三種方法。需要的朋友可以過來參考下,希望對大家有所幫助2013-10-10