cocos2d-x 滚动条实现

CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
CCControlSlider *slider = CCControlSlider::create("extensions/sliderTrack.png","extensions/sliderProgress.png" ,"extensions/sliderThumb.png");
//slider->addTargetWithActionForControlEvents(this, menu_selector(HelloWorld::actionSlider),CCControlEventValueChanged);   事件
		
slider->setAnchorPoint(ccp(0.5f, 1.0f));
		
slider->setMinimumValue(0.0f); 
// Sets the min value of range
		
slider->setMaximumValue(3.0f); 
// Sets the max value of range
		
slider->setValue(1.0f);
		
slider->setPosition(ccp(screenSize.width / 2.0f, 35));
		
this->addChild(slider);

如果找不到CCControlSlider类 那就

#include "cocos-ext.h"
USING_NS_CC_EXT;

如果无法导入此文件 那就

项目下配置

附加包含目录   $(SolutionDir)extensions
附加依赖项  libExtensions.lib

你可能感兴趣的:(cocos2d-x 滚动条实现)