前端之家收集整理的这篇文章主要介绍了
Cocos2d-x_CCControlSlider(滑动条类)介绍,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
bool HelloWorld::init()
{
if ( !CCLayer::init() )
{
return false;
}
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
CCControlSlider *slider = CCControlSlider::create("sliderBg.png","sliderProgress.png","sliderThumb.png");
slider->setMaximumAllowedValue(100);
slider->setMinimumAllowedValue(0);
slider->setPosition(ccp(200,170));
slider->addTargetWithActionForControlEvents(this,cccontrol_selector(HelloWorld::valueChange),CCControlEventValueChanged);
this->addChild(slider);
return true;
}
void HelloWorld::valueChange(CCObject *pSender)
{
CCControlSlider *slider = (CCControlSlider *)pSender;
float value = slider->getValue();
CCLog("value:%.2f",value);
}
原文链接:https://www.f2er.com/cocos2dx/346813.html