当前位置: 首页>>代码示例>>C++>>正文


C++ LoadingBar::clone方法代码示例

本文整理汇总了C++中LoadingBar::clone方法的典型用法代码示例。如果您正苦于以下问题:C++ LoadingBar::clone方法的具体用法?C++ LoadingBar::clone怎么用?C++ LoadingBar::clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LoadingBar的用法示例。


在下文中一共展示了LoadingBar::clone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: init

bool UILoadingBarTest_Direction::init()
{
    if (UIScene::init())
    {
        //scheduleUpdate();

        Size widgetSize = _widget->getContentSize();

        // Add the alert
        Text* alert = Text::create("Test LoadingBar Change Direction",
            "fonts/Marker Felt.ttf", 30);
        alert->setColor(Color3B(159, 168, 176));
        alert->setPosition(Vec2(widgetSize.width / 2.0f,
            widgetSize.height / 2.0f - alert->getContentSize().height * 1.75f));
        _uiLayer->addChild(alert);

        // Create the loading bar
        LoadingBar* loadingBar = LoadingBar::create("cocosui/sliderProgress.png");
        loadingBar->setTag(0);
        loadingBar->setPercent(80);
        loadingBar->setPosition(Vec2(widgetSize.width / 2.0f,
            widgetSize.height / 2.0f + loadingBar->getContentSize().height / 4.0f));

        auto loadingBarCopy = (LoadingBar*)loadingBar->clone();
        loadingBarCopy->setTag(1);
        loadingBarCopy->setPosition(loadingBar->getPosition()
            + Vec2(0, -40));
        loadingBarCopy->setDirection(LoadingBar::Direction::RIGHT);

        Button* button = Button::create("cocosui/animationbuttonnormal.png",
            "cocosui/animationbuttonpressed.png");
        button->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + 50));
        button->setTitleText("Click to change direction!");

        button->addTouchEventListener([=](Ref*, Widget::TouchEventType type)
        {
            if (type == Widget::TouchEventType::ENDED)
            {
                if (loadingBar->getDirection() == LoadingBar::Direction::LEFT)
                {
                    loadingBar->setDirection(LoadingBar::Direction::RIGHT);
                    loadingBarCopy->setDirection(LoadingBar::Direction::LEFT);
                }
                else
                {
                    loadingBar->setDirection(LoadingBar::Direction::LEFT);
                    loadingBarCopy->setDirection(LoadingBar::Direction::RIGHT);
                }
            }
        });
        _uiLayer->addChild(loadingBar, 1);
        _uiLayer->addChild(loadingBarCopy, 2);
        _uiLayer->addChild(button);

        _loadingBar = loadingBar;
        return true;
    }
    return false;
}
开发者ID:anilgulgor,项目名称:myGame,代码行数:59,代码来源:UILoadingBarTest.cpp


注:本文中的LoadingBar::clone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。