Cocos2d-x UI開發(fā)之CCControlPotentiometer控件類使用實(shí)例
更新時間:2014年09月11日 10:45:50 投稿:junjie
這篇文章主要介紹了Cocos2d-x UI開發(fā)之CCControlPotentiometer控件類使用實(shí)例,本文代碼中包含注釋來講解CCControlPotentiometer控件類的使用,需要的朋友可以參考下
CCControlPotentiometer是電位計(jì)按鈕,和CCControlSlider的用法很相似。關(guān)于控件使用時的一些配置,請參見文章:UI開發(fā)之控件類-CCControlButton。
bool HelloWorld::init() { bool bRet = false; do { CC_BREAK_IF(!CCLayer::init()); //CCControlPotentiometer參數(shù)是底座,進(jìn)度條,控制按鈕圖片資源 CCControlPotentiometer * potentiometer = CCControlPotentiometer::create("potentiometerTrack.png", "potentiometerProgress.png","potentiometerButton.png"); //設(shè)置最大值和最小值以及初值 potentiometer->setMaximumValue(100.0); potentiometer->setMinimumValue(0.0); potentiometer->setValue(50); potentiometer->setPosition(ccp(240,160)); this->addChild(potentiometer); //添加事件監(jiān)聽 potentiometer->addTargetWithActionForControlEvents(this,cccontrol_selector(HelloWorld::valueChanged), CCControlEventValueChanged); bRet = true; } while(0); return bRet; } void HelloWorld::valueChanged(CCObject * pSender,CCControlEvent controlEvent) { CCControlPotentiometer * potentiometer = (CCControlPotentiometer *)pSender; CCString * string = CCString::createWithFormat("%f",potentiometer->getValue()); CCLog(string->getCString()); }
相關(guān)文章
C++與namespace有關(guān)的兩個編譯錯誤的講解
今天小編就為大家分享一篇關(guān)于C++與namespace有關(guān)的兩個編譯錯誤的講解,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧2019-04-04