本文整理汇总了C++中ProgressTimer::getParent方法的典型用法代码示例。如果您正苦于以下问题:C++ ProgressTimer::getParent方法的具体用法?C++ ProgressTimer::getParent怎么用?C++ ProgressTimer::getParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProgressTimer
的用法示例。
在下文中一共展示了ProgressTimer::getParent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}