本文整理汇总了C++中MapEntity::get_facing_entity方法的典型用法代码示例。如果您正苦于以下问题:C++ MapEntity::get_facing_entity方法的具体用法?C++ MapEntity::get_facing_entity怎么用?C++ MapEntity::get_facing_entity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MapEntity
的用法示例。
在下文中一共展示了MapEntity::get_facing_entity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: check_collision
/**
* \brief Checks whether an entity collides with this detector.
*
* This function is called by the map when an entity has just moved.
* It checks whether the entity collides with this detector.
* Depending on the detector collision mode(s), the appropriate
* test_collision_* functions are called.
* If there is a collision, the notify_collision() method is called.
*
* \param entity the entity to check
*/
void Detector::check_collision(MapEntity& entity) {
if (&entity != this
&& (has_layer_independent_collisions() || get_layer() == entity.get_layer())) { // the entity is in the same layer as the detector
// detect the collision depending on the collision mode
if (has_collision_mode(COLLISION_OVERLAPPING) && test_collision_rectangle(entity)) {
notify_collision(entity, COLLISION_OVERLAPPING);
}
if (has_collision_mode(COLLISION_CONTAINING) && test_collision_inside(entity)) {
notify_collision(entity, COLLISION_CONTAINING);
}
if (has_collision_mode(COLLISION_ORIGIN) && test_collision_origin_point(entity)) {
notify_collision(entity, COLLISION_ORIGIN);
}
if (has_collision_mode(COLLISION_FACING) && test_collision_facing_point(entity)) {
if (entity.get_facing_entity() == NULL) { // make sure only one entity can think "I am the facing entity"
entity.set_facing_entity(this);
}
notify_collision(entity, COLLISION_FACING);
}
if (has_collision_mode(COLLISION_TOUCHING) && test_collision_touching(entity)) {
notify_collision(entity, COLLISION_TOUCHING);
}
if (has_collision_mode(COLLISION_CENTER) && test_collision_center(entity)) {
notify_collision(entity, COLLISION_CENTER);
}
if (has_collision_mode(COLLISION_CUSTOM) && test_collision_custom(entity)) {
notify_collision(entity, COLLISION_CUSTOM);
}
}
}