cocos代码研究(18)Widget子类Slider学习笔记
理论基础
滑动条控件。
代码实践
实例:
// Create the slider Slider* slider = Slider::create(); slider->loadBarTexture("cocosui/sliderTrack.png"); slider->loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", ""); slider->loadProgressBarTexture("cocosui/sliderProgress.png"); slider->setMaxPercent(10000); slider->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f/* + slider->getSize().height * 2.0f*/)); slider->addEventListener(CC_CALLBACK_2(UISliderTest::sliderEvent, this)); _uiLayer->addChild(slider);