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


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

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


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

示例1: scheduleUpdate

bool UILoadingBarTest_Right_Scale9::init()
{
    if (UIScene::init())
    {
        scheduleUpdate();
        
        Size widgetSize = _widget->getSize();
        
        // Add the alert
        Text *alert = Text::create();
        alert->setText("LoadingBar right scale9 render");
        alert->setFontName("Marker Felt");
        alert->setFontSize(20);
        alert->setColor(Color3B(159, 168, 176));
        alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 2.7f));
        _uiLayer->addChild(alert);
        
        // Create the loading bar
        LoadingBar* loadingBar = LoadingBar::create();
        loadingBar->setTag(0);
        loadingBar->loadTexture("cocosui/slider_bar_active_9patch.png");
        loadingBar->setScale9Enabled(true);
        loadingBar->setCapInsets(Rect(0, 0, 0, 0));
        loadingBar->setSize(Size(300, loadingBar->getContentSize().height));
        loadingBar->setDirection(LoadingBarTypeRight);        
        loadingBar->setPercent(0);
        
        loadingBar->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + loadingBar->getSize().height / 4.0f));
        _uiLayer->addChild(loadingBar);
        
        return true;
    }
    return false;
}
开发者ID:ntotani,项目名称:amiconveyor,代码行数:34,代码来源:UILoadingBarTest.cpp

示例2: init

bool UILoadingBarReloadTexture::init()
{
    if (UIScene::init())
    {
        Size widgetSize = _widget->getContentSize();
        
        // Add the alert
        Text *alert = Text::create("Click button to Toggle Scale9 and switch Texture.", "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);
        
        LoadingBar* loadingBar = LoadingBar::create("cocosui/slider_bar_active_9patch.png");
        loadingBar->setTag(0);
        loadingBar->ignoreContentAdaptWithSize(false);
//        loadingBar->setScale9Enabled(true);
        loadingBar->setCapInsets(Rect(0, 0, 0, 0));
        loadingBar->setContentSize(Size(300, 13));
        loadingBar->setName("texture0");
        loadingBar->setDirection(LoadingBar::Direction::RIGHT);
        loadingBar->setPercent(70);
        loadingBar->setPosition(Vec2(widgetSize.width / 2.0f,
                                     widgetSize.height / 2.0f + loadingBar->getContentSize().height / 4.0f));
        
        _uiLayer->addChild(loadingBar);
        
        auto buttonScale9 = Button::create("cocosui/animationbuttonnormal.png",
                                           "cocosui/animationbuttonpressed.png");
        buttonScale9->setTitleText("ToggleScale9");
        buttonScale9->addClickEventListener([=](Ref*){
            loadingBar->setScale9Enabled(!loadingBar->isScale9Enabled());
        });
        buttonScale9->setPosition(loadingBar->getPosition() + Vec2(-50,50));
        _uiLayer->addChild(buttonScale9);
        
        auto buttonChangeTexture = Button::create("cocosui/animationbuttonnormal.png",
                                                  "cocosui/animationbuttonpressed.png");
        buttonChangeTexture->setTitleText("ChangeTexture");
        buttonChangeTexture->addClickEventListener([=](Ref*){
            auto name = loadingBar->getName();
            if (name == "texture0")
            {
                loadingBar->loadTexture("cocosui/slider_bar_active_9patch2.png");
                loadingBar->setName("texture1");
            }
            else
            {
                loadingBar->loadTexture("cocosui/slider_bar_active_9patch.png");
                loadingBar->setName("texture0");
            }
        });
        buttonChangeTexture->setPosition(loadingBar->getPosition() + Vec2(50,50));
        _uiLayer->addChild(buttonChangeTexture);
        
        this->scheduleUpdate();
        return true;
    }
    return false;
}
开发者ID:anilgulgor,项目名称:myGame,代码行数:60,代码来源:UILoadingBarTest.cpp

示例3: init

bool UILoadingBarTest_Left::init()
{
    if (UIScene::init())
    {
        scheduleUpdate();
        
        Size widgetSize = _widget->getSize();
        
        // Add the alert
        Text* alert = Text::create();
        alert->setText("LoadingBar left");
        alert->setFontName("Marker Felt");
        alert->setFontSize(30);
        alert->setColor(Color3B(159, 168, 176));
        alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
        _uiLayer->addChild(alert);
        
        // Create the loading bar
        LoadingBar* loadingBar = LoadingBar::create();
        loadingBar->setTag(0);
        loadingBar->loadTexture("cocosui/sliderProgress.png");
        loadingBar->setPercent(0);
        
        loadingBar->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + loadingBar->getSize().height / 4.0f));
        _uiLayer->addChild(loadingBar);
        
        return true;
    }
    return false;
}
开发者ID:ntotani,项目名称:amiconveyor,代码行数:30,代码来源:UILoadingBarTest.cpp

示例4: scheduleUpdate

bool UILoadingBarTest_Left_Scale9::init()
{
    if (UIScene::init())
    {
        scheduleUpdate();
        
        Size widgetSize = _widget->getContentSize();
        
        // Add the alert
        Text* alert = Text::create("LoadingBar left 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/slider_bar_active_9patch.png");
        loadingBar->setTag(0);
        loadingBar->setScale9Enabled(true);
        loadingBar->setCapInsets(Rect(0, 0, 0, 0));
        loadingBar->setContentSize(Size(300, 13));
        
        loadingBar->setPosition(Vec2(widgetSize.width / 2.0f,
                                      widgetSize.height / 2.0f + loadingBar->getContentSize().height / 4.0f));
        
        _uiLayer->addChild(loadingBar);
        
        return true;
    }
    return false;
}
开发者ID:anilgulgor,项目名称:myGame,代码行数:30,代码来源:UILoadingBarTest.cpp

示例5:

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;
}
开发者ID:anilgulgor,项目名称:myGame,代码行数:43,代码来源:UILoadingBarTest.cpp

示例6: setupMonster

void monster::setupMonster()
{
    auto s = Director::getInstance()->getWinSize();
    //remove sigle resource
    ArmatureDataManager::getInstance()->removeArmatureFileInfo("Export/dongzuo.ExportJson");
    //load resource directly
    ArmatureDataManager::getInstance()->addArmatureFileInfo("Export/dongzuo.ExportJson");
    _pMonsterArmature = Armature::create("dongzuo");
    _pMonsterArmature->getAnimation()->playWithIndex(0);
    addChild(_pMonsterArmature,0,0);
    _pMonsterArmature->setPosition(Point(_pMonsterArmature->getContentSize().width,
                                s.height - _pMonsterArmature->getContentSize().height-50));
    
    _pMonsterArmature->setPosition(Point(s.width*0.8,
                              s.height - _pMonsterArmature->getContentSize().height-50));
    _monster_pos = _pMonsterArmature->getPosition();
    

    auto body = PhysicsBody::createCircle(_pMonsterArmature->getContentSize().width/3);
    body->setCategoryBitmask(0x01);
    body->setCollisionBitmask(0x01);
    body->setDynamic(false);
    _pMonsterArmature->setPhysicsBody(body);

    //setup monster hp
    auto bkbar = Sprite::create("slidbar.png");
    bkbar->setColor(Color3B::GRAY);
    addChild(bkbar,0,kMonsterHp);
    bkbar->setPosition(Point(Point(_monster_pos.x, _monster_pos.y - _pMonsterArmature->getContentSize().height/2-5)));
    
    LoadingBar* monsterHpBar = LoadingBar::create();
    monsterHpBar->setTag(0);
    monsterHpBar->loadTexture("slidbar.png");
    monsterHpBar->setDirection(LoadingBarTypeLeft);
    monsterHpBar->setPercent(50);
    monsterHpBar->setPosition(Point(bkbar->getContentSize().width/2, bkbar->getContentSize().height/2));
    bkbar->addChild(monsterHpBar,0,0);
}
开发者ID:rickystone,项目名称:Match2,代码行数:38,代码来源:monster.cpp

示例7: init

bool Upgrade::init()
{
//	CCLog("%s:%d", __FILE__, __LINE__);

		if (!Layer::init())
		{
			return false;
		}


	Size winSize = Director::getInstance()->getWinSize();

	//获取本地版本
	CCLOG("xml----location----%s", UserDefault::getInstance()->getXMLFilePath().c_str());
	std::string s =	UserDefault::getInstance()->getXMLFilePath().c_str();
//	CCLog("%s:%d", s.c_str(), __LINE__);
	


	//创建下载目录文件夹
	initDownloadDir();

	//加载tips 提示信息
	loadTipsInfo();


	LoadingBar *pLoadingBar = LoadingBar::create("load.png");
	pLoadingBar->setTag(1001);
	pLoadingBar->setPosition(Vec2(winSize.width / 2, 100));

	this->addChild(pLoadingBar);


	_showDownloadInfo = Label::create();
	_showDownloadInfo->setString("");
	_showDownloadInfo->setSystemFontSize(20);

	this->addChild(_showDownloadInfo);
	_showDownloadInfo->setPosition(Vec2(winSize.width / 2, winSize.height / 2 - 20));

	//提示label
	tipsLabel = Label::create();
	tipsLabel->setString(TipsVer[0]);
	tipsLabel->setSystemFontSize(20);
	tipsLabel->setTag(1002);
	tipsLabel->setPosition(Vec2(winSize.width / 2, winSize.height / 2+20));
	this->addChild(tipsLabel);



	//淡出淡出
	auto *fadeout = FadeOut::create(1.5f);
	auto *fadein = FadeIn::create(1.5f);
	auto *repeatForever = RepeatForever::create(Sequence::create(fadeout,
																CallFunc::create(CC_CALLBACK_0(Upgrade::actionCallBacn, this)),
																fadein,
																DelayTime::create(2.0f),
																nullptr));
	tipsLabel->runAction(repeatForever);


	upgrade();

	return true;
}
开发者ID:Super-Man,项目名称:cocos2dx-Updata,代码行数:65,代码来源:Upgrade.cpp


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