cocos2dx CCControlSlider
2014-05-01 21:35
239 查看
有的同学建议先上图,好吧,先上效果图
再看代码,创建了两个CCControlSlider在主窗口中
简单的创建了两个CCControlSlider
再看代码,创建了两个CCControlSlider在主窗口中
// on "init" you need to initialize your instance bool ControlSlider01::init() { ////////////////////////////// // 1. super init first if ( !MenuLayer::init() ) { return false; } CCSize screenSize = CCDirector::sharedDirector()->getWinSize(); // Add the slider CCControlSlider *slider = CCControlSlider::create("extensions/sliderTrack.png","extensions/sliderProgress.png" ,"extensions/sliderThumb.png"); slider->setAnchorPoint(ccp(0.5f, 1.0f)); slider->setMinimumValue(0.0f); // Sets the min value of range slider->setMaximumValue(5.0f); // Sets the max value of range slider->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f + 16)); slider->setTag(1); // When the value of the slider will change, the given selector will be call slider->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlSlider01::valueChanged), CCControlEventValueChanged); CCControlSlider *restrictSlider = CCControlSlider::create("extensions/sliderTrack.png","extensions/sliderProgress.png" ,"extensions/sliderThumb.png"); restrictSlider->setAnchorPoint(ccp(0.5f, 1.0f)); restrictSlider->setMinimumValue(0.0f); // Sets the min value of range restrictSlider->setMaximumValue(5.0f); // Sets the max value of range restrictSlider->setMaximumAllowedValue(4.0f); restrictSlider->setMinimumAllowedValue(1.5f); restrictSlider->setValue(3.0f); restrictSlider->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f - 24)); restrictSlider->setTag(2); //same with restricted restrictSlider->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlSlider01::valueChanged), CCControlEventValueChanged); addChild(slider); addChild(restrictSlider); return true; } void ControlSlider01::valueChanged(CCObject* obj, CCControlEvent) { CCControlSlider* slider = (CCControlSlider*)obj; float val = slider->getValue(); CCLOG("%f", val); }
简单的创建了两个CCControlSlider
相关文章推荐
- cocos2dX UI控件之CCControlSlider
- cocos2dx CCControlSlider
- 1cocos2dx扩展库UI控件,CCControlSlider,CCScale9Sprite(九妹图),CCControlSwitch,CCControlButton
- 和屌丝一起学cocos2dx-CCControlSlider
- cocos2dx-CCControlSlider
- cocos2dx之创建CCControlSlider
- cocos2dx CCControlSlider 滑动条
- 【Cocos2d-x】添加CCControlSlider的头文件
- CCControlSlider 滑动条
- CCControlSlider滑动按钮学习笔记
- CCControlSwitch 、CCControlSlider、CCControlButton
- Cocos2d-x学习笔记(12)(CCControlSwitch开关、CCControlSlider滑动条、CCControlButtonbutton)
- Cocos2d-x控件使用CCControlSlider<代码演示>
- cocos2dx CCControlSwitch
- cocos2d详细 类之CCControlSlider
- cocos2dx CCControlButton 按钮事件
- cocos2dx CCControlSwitch
- cocos2dX UI控件之CCControlButton
- UI开发之控件类-CCControlSlider
- cocos2d-x-2.0新增加了几个UI控件,这里我介绍下常用的这几个UI控件(CCControlSlider、CCControlSwitch、CCControlColourPicker)使用方法