Cocos2d-x UI開(kāi)發(fā)之CCControlPotentiometer控件類(lèi)使用實(shí)例
更新時(shí)間:2014年09月11日 10:45:50 投稿:junjie
這篇文章主要介紹了Cocos2d-x UI開(kāi)發(fā)之CCControlPotentiometer控件類(lèi)使用實(shí)例,本文代碼中包含注釋來(lái)講解CCControlPotentiometer控件類(lèi)的使用,需要的朋友可以參考下
CCControlPotentiometer是電位計(jì)按鈕,和CCControlSlider的用法很相似。關(guān)于控件使用時(shí)的一些配置,請(qǐng)參見(jiàn)文章:UI開(kāi)發(fā)之控件類(lèi)-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)聽(tīng)
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());
}
您可能感興趣的文章:
- Cocos2d-x UI開(kāi)發(fā)之CCControlSwitch控件類(lèi)使用實(shí)例
- Cocos2d-x UI開(kāi)發(fā)之CCControlColourPicker控件類(lèi)使用實(shí)例
- Cocos2d-x UI開(kāi)發(fā)之CCControlSlider控件類(lèi)使用實(shí)例
- Cocos2d-x UI開(kāi)發(fā)之CCControlButton控件類(lèi)實(shí)例
- Cocos2d-x UI開(kāi)發(fā)之場(chǎng)景切換代碼實(shí)例
- Cocos2d-x UI開(kāi)發(fā)之菜單類(lèi)使用實(shí)例
- Cocos2d-x UI開(kāi)發(fā)之文本類(lèi)使用實(shí)例
相關(guān)文章
C#使用反射加載多個(gè)程序集的實(shí)現(xiàn)方法
下面小編就為大家?guī)?lái)一篇C#使用反射加載多個(gè)程序集的實(shí)現(xiàn)方法。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2016-06-06
C語(yǔ)言實(shí)現(xiàn)維吉尼亞密碼的示例代碼
維吉尼亞密碼(又譯維熱納爾密碼)是使用一系列凱撒密碼組成密碼字母表的加密算法,屬于多表密碼的一種簡(jiǎn)單形式。本文將用C語(yǔ)言實(shí)現(xiàn)維吉尼亞密碼,需要的可以參考一下2022-11-11
C++與namespace有關(guān)的兩個(gè)編譯錯(cuò)誤的講解
今天小編就為大家分享一篇關(guān)于C++與namespace有關(guān)的兩個(gè)編譯錯(cuò)誤的講解,小編覺(jué)得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧2019-04-04
C語(yǔ)言 以字符串的形式讀寫(xiě)文件詳解及示例代碼
本文主要介紹 C語(yǔ)言以字符串的形式讀寫(xiě)文件,這里提供了詳細(xì)的資料及簡(jiǎn)單示例代碼以便大家學(xué)習(xí)參考,有學(xué)習(xí)此部分的小伙伴可以參考下2016-08-08

