本文整理汇总了C++中setPercent函数的典型用法代码示例。如果您正苦于以下问题:C++ setPercent函数的具体用法?C++ setPercent怎么用?C++ setPercent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setPercent函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: setPercent
void CreateProgPage::onProgress(MCFCore::Misc::ProgressInfo& info)
{
setPercent(info.percent);
gcFrame* par = dynamic_cast<gcFrame*>(GetParent());
if (par)
par->setProgress(info.percent);
Update();
}
开发者ID:BlastarIndia,项目名称:Desurium,代码行数:10,代码来源:CreateProgPage.cpp
示例17: setPercent
bool Slider::onTouchBegan(Touch *touch, Event *unusedEvent)
{
bool pass = Widget::onTouchBegan(touch, unusedEvent);
if (_hitted)
{
setPercent(getPercentWithBallPos(_touchBeganPosition));
percentChangedEvent(EventType::ON_SLIDEBALL_DOWN);
}
return pass;
}
开发者ID:bonlai,项目名称:3kaigame,代码行数:10,代码来源:UISlider.cpp
示例18: GlObject
GlPictureFlow::GlPictureFlow(GlObject* parent) : GlObject(parent)
{
setGeometry(0,0,800,300);
setPercent(0);
for_backward = &GlPictureFlow::draw_forward;
buttonLeft = new GlButton(this);
buttonLeft->setGeometry(280,270,60,30);
buttonLeft->setBackGroundPixmap(QPixmap(":/images/pictureFlowLeft.png"));
buttonLeft->setBackGroundPixmapPressed(QPixmap(":/images/pictureFlowLeftPressed.png"));
buttonLeft->setText("<");
connect(buttonLeft, SIGNAL(clicked()), this, SLOT(startForward()));
buttonRigth = new GlButton(this);
buttonRigth->setGeometry(460,270,60,30);
buttonRigth->setBackGroundPixmap(QPixmap(":/images/pictureFlowRigth.png"));
buttonRigth->setBackGroundPixmapPressed(QPixmap(":/images/pictureFlowRigthPressed.png"));
buttonRigth->setText(">");
connect(buttonRigth, SIGNAL(clicked()), this, SLOT(startBackward()));
buttonTracks = new GlButton(this);
buttonTracks->setGeometry(340,270,120,30);
buttonTracks->setBackGroundPixmap(QPixmap(":/images/button120.png"));
buttonTracks->setBackGroundPixmapPressed(QPixmap(":/images/button120Pressed.png"));
buttonTracks->setText("Tracks");
connect(buttonTracks, SIGNAL(clicked()), this, SIGNAL(buttonTracks_Clicked()));
timeLine = new QTimeLine(350, this);
timeLine->setLoopCount(1);
timeLine->setFrameRange(0, 100);
timeLine->setCurveShape(QTimeLine::EaseInCurve);
connect(timeLine, SIGNAL(frameChanged(int)), this, SLOT(newPercent(int)));
connect(timeLine, SIGNAL(finished()), this, SLOT(done()));
distShort = 50;
distLong = 150;
sizeSmall = 130;
sizeBig = 150;
pt0.setX(50); pt0.setY(150);
pt1.setX(100); pt1.setY(150);
pt2.setX(150); pt2.setY(150);
pt3.setX(200); pt3.setY(150);
pt4.setX(250); pt4.setY(150);
pt5.setX(400); pt5.setY(150);
pt6.setX(750); pt6.setY(150);
pt7.setX(700); pt7.setY(150);
pt8.setX(650); pt8.setY(150);
pt9.setX(600); pt9.setY(150);
pt10.setX(550); pt10.setY(150);
pt11.setX(400); pt11.setY(150);
}
开发者ID:mikejg,项目名称:shinyPlayer,代码行数:54,代码来源:glpictureflow.cpp
示例19: setScale9Enabled
void UILoadingBar::copySpecialProperties(UIWidget *widget)
{
UILoadingBar* loadingBar = dynamic_cast<UILoadingBar*>(widget);
if (loadingBar)
{
m_bPrevIgnoreSize = loadingBar->m_bPrevIgnoreSize;
setScale9Enabled(loadingBar->m_bScale9Enabled);
loadTexture(loadingBar->m_strTextureFile.c_str(), loadingBar->m_eRenderBarTexType);
setCapInsets(loadingBar->m_capInsets);
setPercent(loadingBar->m_nPercent);
}
}
开发者ID:DillonJeong,项目名称:cocos2d-x,代码行数:12,代码来源:UILoadingBar.cpp
示例20: DM
void HomeHudLayer::addPlayerExp(int add)
{
DM()->updatePlayerExp(add);
loadData();
// player
auto ui = (Widget*)this->getChildByName("UI");
auto playerLevel = (Text*)Helper::seekWidgetByName(ui, "PlayerLevel");
auto playerBar = (LoadingBar*)Helper::seekWidgetByName(ui, "PlayerBar");
playerLevel->setString(GM()->getIntToStr(_level));
playerBar->setPercent(100.0 * _exp / _expRequire);
}
开发者ID:CYber520CM,项目名称:Cocos_Ring,代码行数:12,代码来源:HomeHudLayer.cpp
注:本文中的setPercent函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论