本文整理汇总了C++中LoadingBar::addTouchEventListener方法的典型用法代码示例。如果您正苦于以下问题:C++ LoadingBar::addTouchEventListener方法的具体用法?C++ LoadingBar::addTouchEventListener怎么用?C++ LoadingBar::addTouchEventListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LoadingBar
的用法示例。
在下文中一共展示了LoadingBar::addTouchEventListener方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool UILoadingBarTest_Scale9_State_Change::init()
{
if (UIScene::init())
{
Size widgetSize = _widget->getContentSize();
// Add the alert
Text *alert = Text::create("LoadingBar right scale9 render", "fonts/Marker Felt.ttf", 20);
alert->setColor(Color3B(159, 168, 176));
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 2.7f));
_uiLayer->addChild(alert);
// Create the loading bar
LoadingBar* loadingBar = LoadingBar::create("cocosui/sliderThumb.png");
loadingBar->setTag(0);
loadingBar->ignoreContentAdaptWithSize(false);
//loadingBar->setScale9Enabled(true);
loadingBar->setCapInsets(Rect(0, 0, 0, 0));
loadingBar->setContentSize(Size(200, 80));
loadingBar->setDirection(LoadingBar::Direction::LEFT);
loadingBar->setPercent(100);
loadingBar->setTouchEnabled(true);
loadingBar->addTouchEventListener([=](Ref* sender, Widget::TouchEventType type){
if (type == Widget::TouchEventType::ENDED) {
if (loadingBar->isScale9Enabled())
{
loadingBar->setScale9Enabled(false);
}
else
loadingBar->setScale9Enabled(true);
}
});
loadingBar->setPosition(Vec2(widgetSize.width / 2.0f,
widgetSize.height / 2.0f + loadingBar->getContentSize().height / 4.0f));
_uiLayer->addChild(loadingBar);
return true;
}
return false;
}