本文整理汇总了C++中EventFrame::getEvent方法的典型用法代码示例。如果您正苦于以下问题:C++ EventFrame::getEvent方法的具体用法?C++ EventFrame::getEvent怎么用?C++ EventFrame::getEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventFrame
的用法示例。
在下文中一共展示了EventFrame::getEvent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onFrameEvent
void AnimationCommandLayer::onFrameEvent(Frame * frame)
{
EventFrame* evnt = dynamic_cast<EventFrame*>(frame);
std::string aniStr = evnt->getEvent();
if (!evnt)
{
return;
}
Sprite* sp = (Sprite*)evnt->getNode();
if (aniStr != "")//spine动画 compare(0, 3, "spi")
{
Player * player = (Player *)sp->getChildByTag(SPINE_ANIMATION_PLAYER_TAG);
player->playRoleAction(aniStr.c_str(), true);
CCLOG("%s Spine Animation is %s", player->getName().c_str(), aniStr.c_str());
}
//暂时去掉下面的代码,如果以后需要执行cocos studio做不出来的动画,那么修改规则,用下面的代码 cuihanbing
// else if (str.compare(0, 3, "act") == 0)//需要cocos2d执行的动画
// {
// if (str == "act_chuxian")
// {
// evnt->getNode()->setOpacity(256);
// CCLOG("Action is %s", str.c_str());
// }
// }
}
示例2: setScore
void ScoreLabel::setScore(int score)
{
this->timeline->play("CountUp", false);
this->timeline->setFrameEventCallFunc([this, score](Frame* frame) {
EventFrame* frameEvent = dynamic_cast<EventFrame*>(frame);
auto eventName = frameEvent->getEvent();
if (eventName == "CountUp") {
this->scoreLabel->setString(std::to_string(score));
}
});
}
示例3: attack
void Entity::attack(const std::string attackName)
{
if (! this->stateMachine->canAttack()) {
return;
}
if (this->stateMachine->isDead()) {
return;
}
EntityAttackParams attackParams = this->getAttackParamsByName(attackName);
std::string particleFilePath = attackParams.particleFilePath;
this->timeline->play(attackName, false);
this->timeline->setFrameEventCallFunc([this, attackName, particleFilePath](Frame* frame) {
EventFrame* frameEvent = dynamic_cast<EventFrame*>(frame);
auto eventName = frameEvent->getEvent();
// log("---- %s ----", eventName.c_str());
if (eventName == "Ready") {
this->currentAttackName = attackName;
this->stateMachine->readyToAttack();
} else if (eventName == "Attack") {
this->stateMachine->startToAttack();
if (particleFilePath != "") {
ParticleSystemQuad* particle = ParticleSystemQuad::create(particleFilePath);
this->addChild(particle);
}
} else if (eventName == "Cooldown") {
this->stateMachine->coolDownAttaking();
} else if (eventName == "Finish") {
this->stateMachine->finishAttaking();
this->currentAttackName = "";
}
});
}