本文整理汇总了C++中BaseGameEntity::getPositionX方法的典型用法代码示例。如果您正苦于以下问题:C++ BaseGameEntity::getPositionX方法的具体用法?C++ BaseGameEntity::getPositionX怎么用?C++ BaseGameEntity::getPositionX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseGameEntity
的用法示例。
在下文中一共展示了BaseGameEntity::getPositionX方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: enter
void HeroHurt::enter(Hero *object)
{
// 面向对你造成伤害者
int entity_id = object->getStateMachine()->userdata().hurt_source;
BaseGameEntity *entity = object->getEntityManger()->getEntityByID(entity_id);
if (entity != nullptr)
{
if (entity->getPositionX() < object->getPositionX())
{
object->setDirection(BaseGameEntity::kLeftDirection);
}
else
{
object->setDirection(BaseGameEntity::kRightDirection);
}
}
system_clock::time_point current_time = system_clock::now();
system_clock::time_point last_hurt_time = object->getStateMachine()->userdata().was_hit_time;
system_clock::duration duration = current_time - last_hurt_time;
if (duration_cast<milliseconds>(duration).count() < 1000)
{
++object->getStateMachine()->userdata().was_hit_count;
}
else
{
object->getStateMachine()->userdata().was_hit_count = 1;
}
if (object->getStateMachine()->userdata().was_hit_count < 3)
{
Animation *animation = AnimationManger::instance()->getAnimation("hero_hurt");
Animate *animate = Animate::create(animation);
animate->setTag(ActionTags::kHeroHurt);
object->runAction(animate);
object->getStateMachine()->userdata().was_hit_time = system_clock::now();
}
else
{
object->getStateMachine()->change_state(HeroKnockout::instance());
}
if (object->hasWeapon())
{
auto current_level = object->getEntityManger()->getCurrentLevel();
current_level->dropWeapon(object);
}
}