コード例 #1
0
ファイル: Detector.cpp プロジェクト: Codex-NG/solarus
/**
 * \brief Sets the collision modes of this detector.
 * \param collision_modes the detector's collision modes
 * (can be an OR combination of collision modes)
 */
void Detector::set_collision_modes(int collision_modes) {

  if (collision_modes & COLLISION_SPRITE) {
    enable_pixel_collisions();
  }
  this->collision_modes = collision_modes;
}
コード例 #2
0
ファイル: Enemy.cpp プロジェクト: joshuarobinson/solarus
/**
 * \brief Sets the map.
 *
 * Warning: when this function is called during the map initialization,
 * the current map of the game is still the old one.
 *
 * \param map The map.
 */
void Enemy::set_map(Map& map) {

  Detector::set_map(map);

  if (is_enabled()) {
    initialize();
    enable_pixel_collisions();
  }

  if (map.is_loaded()) {
    // We are not during the map initialization phase.
    restart();
  }
}
コード例 #3
0
ファイル: Enemy.cpp プロジェクト: j4b0l/solarus
/**
 * \copydoc MapEntity::notify_created
 */
void Enemy::notify_created() {

  Detector::notify_created();

  // At this point, enemy:on_created() was called.
  enable_pixel_collisions();

  // Give sprites their initial direction.
  int initial_direction = get_direction();
  std::vector<Sprite*>::const_iterator it;
  for (it = get_sprites().begin(); it != get_sprites().end(); it++) {
    (*it)->set_current_direction(initial_direction);
  }

  if (is_enabled()) {
    restart();
  }
}