本文整理汇总了C++中ControlSlider::setTag方法的典型用法代码示例。如果您正苦于以下问题:C++ ControlSlider::setTag方法的具体用法?C++ ControlSlider::setTag怎么用?C++ ControlSlider::setTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ControlSlider
的用法示例。
在下文中一共展示了ControlSlider::setTag方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool ControlSliderTest::init()
{
if (ControlScene::init())
{
auto screenSize = Director::getInstance()->getWinSize();
// Add a label in which the slider value will be displayed
_displayValueLabel = LabelTTF::create("Move the slider thumb!\nThe lower slider is restricted." ,"Marker Felt", 32);
_displayValueLabel->retain();
_displayValueLabel->setAnchorPoint(Point(0.5f, -1.0f));
_displayValueLabel->setPosition(Point(screenSize.width / 1.7f, screenSize.height / 2.0f));
addChild(_displayValueLabel);
// Add the slider
ControlSlider *slider = ControlSlider::create("extensions/sliderTrack.png","extensions/sliderProgress.png" ,"extensions/sliderThumb.png");
slider->setAnchorPoint(Point(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(Point(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(ControlSliderTest::valueChanged), Control::EventType::VALUE_CHANGED);
ControlSlider *restrictSlider = ControlSlider::create("extensions/sliderTrack.png","extensions/sliderProgress.png" ,"extensions/sliderThumb.png");
restrictSlider->setAnchorPoint(Point(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(Point(screenSize.width / 2.0f, screenSize.height / 2.0f - 24));
restrictSlider->setTag(2);
//same with restricted
restrictSlider->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlSliderTest::valueChanged), Control::EventType::VALUE_CHANGED);
addChild(slider);
addChild(restrictSlider);
return true;
}
return false;
}