码迷,mamicode.com
首页 > 编程语言 > 详细

Cocos2d-x3.3Final(6)Slider常用成员函数(C++)

时间:2015-02-03 19:34:22      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:

滑动栏:

Slider * slider = Slider::create();

slider->loadBarTexture("sliderTrack.png");//设置滑动栏的背景图片
slider->loadSlidBallTextures("sliderThumb.png", "sliderThumb.png", ""); //滑动栏的滑动按钮图片
slider->loadProgressBarTexture("sliderProgress.png"); //滑动栏的进度图片
slider->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y + 100));
slider->addEventListener(CC_CALLBACK_2(HelloWorld::sliderEvent, this)); //设置事件监听函数

this->addChild(slider);


void HelloWorld::sliderEvent(Ref * pSender, Slider::EventType type)
{
if (type == Slider::EventType::ON_PERCENTAGE_CHANGED)
{
Slider * slider = dynamic_cast<Slider *>(pSender);
int percent = slider->getPercent(); //获取当前滑动的百分比
auto label = static_cast<Label *>(getChildByTag(11));
label->setString(String::createWithFormat("Perfecnt %d", percent)->getCString()); //使用该百分比
}
}

Cocos2d-x3.3Final(6)Slider常用成员函数(C++)

标签:

原文地址:http://blog.csdn.net/lightupheaven/article/details/43452557

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!