如果報(bào)錯(cuò)ui名空間沒有Slider需要包含頭文件#include"ui/CocosGUI.h"
auto slider =ui::Slider::create();
slider->loadBarTexture("login/sliderback.png");//滑動(dòng)條背景
slider->loadSlidBallTextures("login/sliderButton.png","","");
//滑動(dòng)按鈕三個(gè)參數(shù)對(duì)應(yīng)正常唯笙、按下监徘、禁用三種狀態(tài)纯衍,默認(rèn)第四個(gè)參數(shù)為local即本地圖片介陶,另一個(gè)值為plist
slider->loadProgressBarTexture("login/sliderback.png");
//滑動(dòng)條進(jìn)度圖片坛善,即從左至滑動(dòng)按鈕顯示的內(nèi)容
slider->setPosition(cocos2d::Point(500,200));
slider->addEventListener(CC_CALLBACK_2(Home::sliderCallBack,this));//回調(diào)
//回調(diào)函數(shù)
void Home::sliderCallBack(cocos2d::Ref*pSender,ui::Slider::EventTypeeventType)
{
? ? ? ? if(eventType==ui::Slider::EventType::ON_PERCENTAGE_CHANGED)
? ? ? ? {
? ? ? ? ? //當(dāng)滑動(dòng)條改變時(shí)
? ? ? ? ?}
}