Cocos2d-x UI開發(fā)之CCControlPotentiometer控件類使用實(shí)例
更新時(shí)間:2014年09月11日 10:45:50 投稿:junjie
這篇文章主要介紹了Cocos2d-x UI開發(fā)之CCControlPotentiometer控件類使用實(shí)例,本文代碼中包含注釋來講解CCControlPotentiometer控件類的使用,需要的朋友可以參考下
CCControlPotentiometer是電位計(jì)按鈕,和CCControlSlider的用法很相似。關(guān)于控件使用時(shí)的一些配置,請(qǐng)參見文章: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#使用反射加載多個(gè)程序集的實(shí)現(xiàn)方法
下面小編就為大家?guī)硪黄狢#使用反射加載多個(gè)程序集的實(shí)現(xiàn)方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-06-06C++與namespace有關(guān)的兩個(gè)編譯錯(cuò)誤的講解
今天小編就為大家分享一篇關(guān)于C++與namespace有關(guān)的兩個(gè)編譯錯(cuò)誤的講解,小編覺得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來看看吧2019-04-04