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


C++ setPercent函数代码示例

本文整理汇总了C++中setPercent函数的典型用法代码示例。如果您正苦于以下问题:C++ setPercent函数的具体用法?C++ setPercent怎么用?C++ setPercent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: showUI

void WorldHudLayer::showUI()
{
    auto ui = GUIReader::getInstance()->widgetFromJsonFile(UI_LAYER_WORLDHUD);
    this->addChild(ui, 0, "UI");
    
    // HomeButton
    auto btnEnter = (Button*)Helper::seekWidgetByName(ui, "HomeButton");
    btnEnter->addTouchEventListener(CC_CALLBACK_2(WorldHudLayer::btnCallback, this));

    // player
    auto playerName = (Text*)Helper::seekWidgetByName(ui, "PlayerName");
    auto playerLevel = (Text*)Helper::seekWidgetByName(ui, "PlayerLevel");
    auto playerBar = (LoadingBar*)Helper::seekWidgetByName(ui, "PlayerBar");
    playerName->setString(_name);
    playerLevel->setString(GM()->getIntToStr(_level));
    playerBar->setPercent(100.0 * _exp / _expRequire);
    // gold
    auto goldCount = (Text*)Helper::seekWidgetByName(ui, "GoldCount");
    auto goldCapacity = (Text*)Helper::seekWidgetByName(ui, "GoldCapacity");
    auto goldBar = (LoadingBar*)Helper::seekWidgetByName(ui, "GoldBar");
    goldCount->setString(GM()->getIntToStr(_goldCount));
    goldCapacity->setString(GM()->getIntToStr(_goldCapacity));
    goldBar->setPercent(100.0 * _goldCount / _goldCapacity);
    // wood
    auto woodCount = (Text*)Helper::seekWidgetByName(ui, "WoodCount");
    auto woodCapacity = (Text*)Helper::seekWidgetByName(ui, "WoodCapacity");
    auto woodBar = (LoadingBar*)Helper::seekWidgetByName(ui, "WoodBar");
    woodCount->setString(GM()->getIntToStr(_woodCount));
    woodCapacity->setString(GM()->getIntToStr(_woodCapacity));
    woodBar->setPercent(100.0 * _woodCount / _woodCapacity);
    // ring
    auto ringCount = (Text*)Helper::seekWidgetByName(ui, "RingCount");
    ringCount->setString(GM()->getIntToStr(_ringCount));
}
开发者ID:CYber520CM,项目名称:Cocos_Ring,代码行数:34,代码来源:WorldHudLayer.cpp

示例2: setPercent

void UISlider::onTouchMoved(const cocos2d::Point &touchPoint)
{
    cocos2d::Point nsp = _renderer->convertToNodeSpace(touchPoint);
    _slidBallRenderer->setPosition(cocos2d::Point(nsp.x,0));
    setPercent(getPercentWithBallPos(nsp.x));
    percentChangedEvent();
}
开发者ID:CryQ,项目名称:coclua,代码行数:7,代码来源:UISlider.cpp

示例3: update

void GameScene::update(float dt)
{
	auto UIComponent = (cocostudio::ComRender*) UINode->getComponent("gameSceneUI");
	auto UILayer = (Layer*)UIComponent->getNode();
	auto loadingBar = dynamic_cast<LoadingBar*>(UILayer->getChildByTag(GAMESCENE_LOADINGBAR));
	auto labelLevel = dynamic_cast<Text*>(UILayer->getChildByTag(GAMESCENE_LABEL_LEVEL));
	auto labelInfo = dynamic_cast<Text*>(UILayer->getChildByTag(GAMESCENE_LABEL_INFO));
	int currPos = AudioEngine::getInstance()->getPosition();
	int percent = currPos * 100 / AudioEngine::getInstance()->getLength();
	loadingBar->setPercent(percent);
	while ((currPos + preloadTime + setting_lag >= noteline.time))//提前一些生成
	{
		if (noteline.time == 0)break;//读到最后跳出
		int arg1 = noteline.type;
		int arg2 = noteline.length;
		int arg3 = noteline.posX;
		int arg4 = noteline.posY;
		MapUtils::getNoteline();//读取下个音符
		addNewNote(arg1, arg2, arg3, arg4);
	}
	if (!AudioEngine::getInstance()->isPlaying())//一首歌结束则切换到结算界面
	{
		this->unscheduleUpdate();
		auto scene = ClearScene::createScene(labelInfo->getString(), labelLevel->getString());
		Director::getInstance()->replaceScene(TransitionCrossFade::create(2, scene));
	}
}
开发者ID:huzhangyang,项目名称:musicgame,代码行数:27,代码来源:GameScene.cpp

示例4: resumeGame

void GameScene::resumeGame(float dt)
{
	auto UIComponent = (cocostudio::ComRender*) UINode->getComponent("gameSceneUI");
	auto UILayer = (Layer*)UIComponent->getNode();
	auto loadingBar = dynamic_cast<LoadingBar*>(UILayer->getChildByTag(GAMESCENE_LOADINGBAR));
	auto labelCombo = dynamic_cast<Text*>(UILayer->getChildByTag(GAMESCENE_LABEL_COMBO));
	static int calledtime = 0;
	loadingBar->setPercent(calledtime++);
	if (loadingBar->getPercent() == 1)
	{
		labelCombo->setString("READY");
		labelCombo->setOpacity(255);
	}
	if (loadingBar->getPercent() == 50)
		labelCombo->runAction(FadeOut::create(1));
	if (loadingBar->getPercent() == 100)
	{
		this->unscheduleAllSelectors();
		calledtime = 0;
		labelCombo->setString("");
		labelCombo->setOpacity(100);
		for (auto&i : UINode->getChildren())
		{
			i->resume();
			for (auto&j : i->getChildren())
				j->resume();
		}
		AudioEngine::getInstance()->resume();
		this->scheduleUpdate();
	}
}
开发者ID:huzhangyang,项目名称:musicgame,代码行数:31,代码来源:GameScene.cpp

示例5: setScale9Enabled

void Slider::copySpecialProperties(Widget *widget)
{
    Slider* slider = dynamic_cast<Slider*>(widget);
    if (slider)
    {
        _prevIgnoreSize = slider->_prevIgnoreSize;
        setScale9Enabled(slider->_scale9Enabled);

        // clone the inner sprite: https://github.com/cocos2d/cocos2d-x/issues/16928
        slider->_barRenderer->copyTo(_barRenderer);
        setupBarTexture();
        slider->_progressBarRenderer->copyTo(_progressBarRenderer);
        setupProgressBarTexture();

        loadSlidBallTextureNormal(slider->_slidBallNormalRenderer->getSpriteFrame());
        loadSlidBallTexturePressed(slider->_slidBallPressedRenderer->getSpriteFrame());
        loadSlidBallTextureDisabled(slider->_slidBallDisabledRenderer->getSpriteFrame());
        setPercent(slider->getPercent());
        setMaxPercent(slider->getMaxPercent());
        _isSliderBallPressedTextureLoaded = slider->_isSliderBallPressedTextureLoaded;
        _isSliderBallDisabledTexturedLoaded = slider->_isSliderBallDisabledTexturedLoaded;
        _sliderEventListener = slider->_sliderEventListener;
        _sliderEventSelector = slider->_sliderEventSelector;
        _eventCallback = slider->_eventCallback;
        _ccEventCallback = slider->_ccEventCallback;
    }
}
开发者ID:bonlai,项目名称:3kaigame,代码行数:27,代码来源:UISlider.cpp

示例6: LoadingBar

void Load::LoadingBar(float dt)
{
    auto size = Director::getInstance()->getVisibleSize();

    auto lb = dynamic_cast<class LoadingBar*>(getChildByTag(1));
    float per = lb->getPercent() + 1.0f;
    lb->setPercent(per);
   //图片加载
    auto load = Sprite::create("load.png");
    load->setPosition(Vec2(size.width/2-150,size.height/2+60));
    auto moveTo = MoveTo::create(0.6,Vec2( size.width/2+130,size.height/2+60));
    auto seq = Sequence::create(moveTo, NULL);
    load->runAction(seq);
    addChild(load);
    
   if (per==100) {
       unschedule("LoadingBar");
       auto callf=CallFunc::create([this](){
           Director::getInstance()->replaceScene(GameScene::createScene());
       });
       auto seq=Sequence::create(DelayTime::create(1.1), callf,NULL);
       this->runAction(seq);
   }
    
}
开发者ID:joyfish,项目名称:MyGame,代码行数:25,代码来源:Load.cpp

示例7: removeProtectedChild

void LoadingBar::setScale9Enabled(bool enabled)
{
    if (_scale9Enabled == enabled)
    {
        return;
    }
    _scale9Enabled = enabled;
    removeProtectedChild(_barRenderer);
    _barRenderer = nullptr;
    if (_scale9Enabled)
    {
        _barRenderer = extension::Scale9Sprite::create();
    }
    else
    {
        _barRenderer = Sprite::create();
    }
    loadTexture(_textureFile,_renderBarTexType);
    addProtectedChild(_barRenderer, BAR_RENDERER_Z, -1);
    if (_scale9Enabled)
    {
        bool ignoreBefore = _ignoreSize;
        ignoreContentAdaptWithSize(false);
        _prevIgnoreSize = ignoreBefore;
    }
    else
    {
        ignoreContentAdaptWithSize(_prevIgnoreSize);
    }
    setCapInsets(_capInsets);
    setPercent(_percent);
}
开发者ID:AIRIA,项目名称:CreazyBomber,代码行数:32,代码来源:UILoadingBar.cpp

示例8: setPercent

void UISlider::onTouchMoved(const CCPoint &touchPoint)
{
    CCPoint nsp = m_pRenderer->convertToNodeSpace(touchPoint);
    m_pSlidBallRenderer->setPosition(ccp(nsp.x,0));
    setPercent(getPercentWithBallPos(nsp.x));
    percentChangedEvent();
}
开发者ID:109383670,项目名称:cocos2d-x,代码行数:7,代码来源:UISlider.cpp

示例9: convertToNodeSpace

void Slider::onTouchMoved(Touch *touch, Event *unusedEvent)
{
    _touchMovePosition = touch->getLocation();
    Vec2 nsp = convertToNodeSpace(_touchMovePosition);
    setPercent(getPercentWithBallPos(nsp.x));
    percentChangedEvent();
}
开发者ID:Ratel13,项目名称:Cocos2dGame-v3.7,代码行数:7,代码来源:UISlider.cpp

示例10: addChild

bool Load::init()
{
    
    if (!Layer::init()) {
        return false;
    }
    
    auto listenerkey=EventListenerKeyboard::create();
    listenerkey->onKeyReleased=[this](EventKeyboard::KeyCode keyCode, Event* event){
        if(keyCode==EventKeyboard::KeyCode::KEY_BACKSPACE)
        {
            auto interact=Interfactionlayer::create(100);
            this->addChild(interact);
        }
    };
    
    auto size = Director::getInstance()->getVisibleSize();
    
    auto loadbg = Sprite::create("loading_word.png");
    loadbg->setPosition(Vec2(size.width/2,size.height/2-50));
    addChild(loadbg);
    auto bg = Sprite::create("loading_progress_1.png");
    bg->setPosition(Vec2(size.width/2,size.height/2));
    addChild(bg);
    
    auto lb = LoadingBar::create("loading_progress_2.png");
    lb->setPosition(Vec2(size.width/2,size.height/2));
    lb->setDirection(LoadingBar::Direction::LEFT);
    lb->setPercent(0);
    addChild(lb,1,1);//同时设置Tag值为1
    schedule(CC_CALLBACK_1(Load::LoadingBar,this),"LoadingBar");
    return true;
}
开发者ID:joyfish,项目名称:MyGame,代码行数:33,代码来源:Load.cpp

示例11: setPercent

void Slider::barRendererScaleChangedWithSize()
{
    if (_ignoreSize)
    {
        
        _barRenderer->setScale(1.0f);
        _size = _barRenderer->getContentSize();
        _barLength = _size.width;
    }
    else
    {
        _barLength = _size.width;
        if (_scale9Enabled)
        {
            static_cast<extension::CCScale9Sprite*>(_barRenderer)->setPreferredSize(_size);
        }
        else
        {
            CCSize btextureSize = _barRenderer->getContentSize();
            if (btextureSize.width <= 0.0f || btextureSize.height <= 0.0f)
            {
                _barRenderer->setScale(1.0f);
                return;
            }
            float bscaleX = _size.width / btextureSize.width;
            float bscaleY = _size.height / btextureSize.height;
            _barRenderer->setScaleX(bscaleX);
            _barRenderer->setScaleY(bscaleY);
        }
    }
    setPercent(_percent);
}
开发者ID:birdcpe25,项目名称:cocos2d-x,代码行数:32,代码来源:UISlider.cpp

示例12: setPercent

	void GUISlider::setValue(float value)
	{
		float diff = mMaxRange - mMinRange;
		float pct = (value - mMinRange) / diff;

		setPercent(pct);
	}
开发者ID:lysannschlegel,项目名称:bsf,代码行数:7,代码来源:BsGUISlider.cpp

示例13: setScale9Enabled

void Slider::copySpecialProperties(Widget *widget)
{
    Slider* slider = dynamic_cast<Slider*>(widget);
    if (slider)
    {
        _prevIgnoreSize = slider->_prevIgnoreSize;
        setScale9Enabled(slider->_scale9Enabled);
        auto barSprite = slider->_barRenderer->getSprite();
        if (nullptr != barSprite)
        {
            loadBarTexture(barSprite->getSpriteFrame());
        }
        auto progressSprite = slider->_progressBarRenderer->getSprite();
        if (nullptr != progressSprite)
        {
            loadProgressBarTexture(progressSprite->getSpriteFrame());
        }
        loadSlidBallTextureNormal(slider->_slidBallNormalRenderer->getSpriteFrame());
        loadSlidBallTexturePressed(slider->_slidBallPressedRenderer->getSpriteFrame());
        loadSlidBallTextureDisabled(slider->_slidBallDisabledRenderer->getSpriteFrame());
        setPercent(slider->getPercent());
        setMaxPercent(slider->getMaxPercent());
        _isSliderBallPressedTextureLoaded = slider->_isSliderBallPressedTextureLoaded;
        _isSliderBallDisabledTexturedLoaded = slider->_isSliderBallDisabledTexturedLoaded;
        _sliderEventListener = slider->_sliderEventListener;
        _sliderEventSelector = slider->_sliderEventSelector;
        _eventCallback = slider->_eventCallback;
        _ccEventCallback = slider->_ccEventCallback;
    }
}
开发者ID:kaiqinetwork,项目名称:cocos2d-x,代码行数:30,代码来源:UISlider.cpp

示例14: convertToNodeSpace

void Slider::onTouchMoved(CCTouch *touch, CCEvent *unused_event)
{
    _touchMovePos = touch->getLocation();
    CCPoint nsp = convertToNodeSpace(_touchMovePos);
    _slidBallRenderer->setPosition(CCPoint(nsp.x,0));
    setPercent(getPercentWithBallPos(nsp.x));
    percentChangedEvent();
}
开发者ID:birdcpe25,项目名称:cocos2d-x,代码行数:8,代码来源:UISlider.cpp

示例15: setPercent

void UIProgressRect::onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode)
{
    UIWidget::onStyleApply(styleName, styleNode);

    for(const OTMLNodePtr& node : styleNode->children()) {
        if(node->tag() == "percent")
            setPercent(node->value<float>());
    }
}
开发者ID:JoseEduardo,项目名称:otclient,代码行数:9,代码来源:uiprogressrect.cpp


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