cocos代码研究(18)Widget子类Slider学习笔记

时间:2023-11-24 19:48:20

理论基础

滑动条控件。

代码实践

实例:

        // 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();
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);