本文整理汇总了C++中ProgressTimer::setPercentage方法的典型用法代码示例。如果您正苦于以下问题:C++ ProgressTimer::setPercentage方法的具体用法?C++ ProgressTimer::setPercentage怎么用?C++ ProgressTimer::setPercentage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProgressTimer
的用法示例。
在下文中一共展示了ProgressTimer::setPercentage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: progressTimerNodeWithRenderTexture
ProgressTimer* TransitionProgressRadialCW::progressTimerNodeWithRenderTexture(RenderTexture* texture)
{
Size size = Director::getInstance()->getWinSize();
ProgressTimer* node = ProgressTimer::create(texture->getSprite());
// but it is flipped upside down so we flip the sprite
node->getSprite()->setFlippedY(true);
node->setType( ProgressTimer::Type::RADIAL );
// Return the radial type that we want to use
node->setReverseDirection(true);
node->setPercentage(100);
node->setPosition(Vector2(size.width/2, size.height/2));
node->setAnchorPoint(Vector2(0.5f,0.5f));
return node;
}
示例2: init
//.........这里部分代码省略.........
right_btn->setScale(0.3);
right_btn->setPosition(Point(250, 125));
right_btn->setTag(TAG_RIGHT);
this->addChild(right_btn,1);
auto up_btn = Sprite::create("up.png");
up_btn->setScale(0.3);
up_btn->setPosition(Point(175, 200));
up_btn->setTag(TAG_UP);
this->addChild(up_btn,1);
auto down_btn = Sprite::create("down.png");
down_btn->setScale(0.3);
down_btn->setPosition(Point(175, 50));
down_btn->setTag(TAG_DOWN);
this->addChild(down_btn,1);
auto attack_btn = Sprite::create("attack.png");
attack_btn->setScale(0.5);
attack_btn->setPosition(positionForTileCoord(Point(25,16)));
attack_btn->setTag(ATTACK);
this->addChild(attack_btn,1);
//hero hp
Sprite *heroEmHP = Sprite::create("empty.png");
heroEmHP->setPosition(Point(150, 600));
heroEmHP->setScale(1.5);
this->addChild(heroEmHP);
Sprite* heroFuHP = Sprite::create("full.png");
ProgressTimer *pBlood = ProgressTimer::create(heroFuHP);
pBlood->setType(kCCProgressTimerTypeBar);
pBlood->setMidpoint(Point(0, 0));
pBlood->setBarChangeRate(Point(1, 0));
pBlood->setPercentage(100.0f);
pBlood->setPosition(Point(150, 600));
pBlood->setScale(1.5);
this->addChild(pBlood, 1, 6);
auto hero =Sprite::create("hero.png");
hero->setPosition(Point(50, 600));
hero->setScale(0.3);
this->addChild(hero);
//patrol monster hp
Sprite *enEmHP = Sprite::create("empty.png");
enEmHP->setPosition(Point(150, 550));
enEmHP->setScale(1.5);
this->addChild(enEmHP,1,7);
Sprite* enFuHP = Sprite::create("full.png");
ProgressTimer *enpBlood = ProgressTimer::create(enFuHP);
enpBlood->setType(kCCProgressTimerTypeBar);
enpBlood->setMidpoint(Point(0, 0));
enpBlood->setBarChangeRate(Point(1, 0));
enpBlood->setPercentage(100.0f);
enpBlood->setPosition(Point(150, 550));
enpBlood->setScale(1.5);
this->addChild(enpBlood, 1,8);
auto monster = Sprite::create("monster.png");
monster->setPosition(Point(50,550));
monster->setScale(0.1);
monster->setTag(9);
this->addChild(monster);
//archer
Sprite *arEmHP = Sprite::create("empty.png");
arEmHP->setPosition(Point(350, 600));
arEmHP->setScale(1.5);
示例3: addTouchListener
void GameScene::addTouchListener()
{
auto touchListener = EventListenerTouchOneByOne::create();
touchListener->onTouchBegan = [this](Touch* t,Event* e)->bool{
auto menuCoo = menu->convertToNodeSpace(t->getLocation());
Rect oldAABB = buttonCoco->getBoundingBox();
Vec2 oldVec = oldAABB.origin;
Vec2 newVec = oldVec-buttonCoco->getContentSize()/2;
Rect newAABB(newVec.x,newVec.y,oldAABB.size.width,oldAABB.size.height);
if(mpProgressTimer->getPercentage()==100.0f&&newAABB.containsPoint(menuCoo)){
isMagic = true;
coco->playAnimation(BaseSprite::State::magic);
if(!eff){
eff = EffSprite::create("pfca/effect/eff_point_Coco_ult.fca", "effect/eff_point_Coco_ult");
this->addChild(eff);
}
eff->setVisible(true);
eff->setPosition(0-_director->getWinSize().width/2,0);
eff->playAnimation(BaseSprite::State::magic,CallFunc::create(CC_CALLBACK_0(GameScene::effectCallback, this)));
mpProgressTimer->setPercentage(0.f);
}
return true;
};
auto hurtLisener = EventListenerCustom::create("hurt", [this](EventCustom* e)->void{
auto hurtObject = (BaseSprite*)e->getUserData();
Label* l = nullptr;
ProgressTimer* hp = nullptr;
if(hurtObject==boss){
l = l1;
hp = effectHpProgressTimer[0];
}else{
l = l2;
hp = effectHpProgressTimer[1];
}
if(dynamic_cast<TreeBoss*>(hurtObject)){
l->setPosition(hurtObject->getPosition()+Vec2(_director->getWinSize().width/2,_director->getWinSize().height/2+200));
hp->setPosition(hurtObject->getPosition()+Vec2(_director->getWinSize().width/2,_director->getWinSize().height/2+180));
}
else{
l->setPosition(hurtObject->getPosition()+Vec2(_director->getWinSize().width/2,_director->getWinSize().height/2+100));
hp->setPosition(hurtObject->getPosition()+Vec2(_director->getWinSize().width/2,_director->getWinSize().height/2+130));
}
hp->setPercentage((hurtObject->getProperty().curLife/hurtObject->getProperty().maxLife)*100);
l->setString("-"+Value((int)hurtObject->getCurHurt()).asString());
if(!l->getParent()){
this->addChild(l,3);
}
if(!hp->getParent()){
this->addChild(hp,3);
}
hp->setVisible(true);
if(!l->isVisible()){
l->setVisible(true);
l->setOpacity(255);
}
auto move = MoveBy::create(0.5f, Vec2(0,20));
auto fade = FadeOut::create(0.5f);
l->runAction(Sequence::create(move, fade,CallFunc::create(std::bind(&GameScene::lableCallback, this,l)),nullptr));
hp->runAction(Sequence::create(DelayTime::create(1.0f),CallFuncN::create([](Node* n){
n->setVisible(false);
}), NULL));
});
_eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener,buttonCoco);
_eventDispatcher->addEventListenerWithSceneGraphPriority(hurtLisener,this);
}