コード例 #1
0
ファイル: Enemy.cpp プロジェクト: j4b0l/solarus
/**
 * \brief Notifies this enemy that it should restart his movement.
 *
 * This function is called when the enemy needs to restart its movement
 * because something happened (for example the enemy has just been created,
 * or it was just hurt).
 * By default, the "walking" animation is set on the enemy's sprites.
 *
 * Nothing happens if the enemy is dying.
 */
void Enemy::restart() {

  if (is_dying()) {
    return;
  }

  if (is_immobilized()) {
    stop_immobilized();
  }
  set_animation("walking");
  get_lua_context().enemy_on_restarted(*this);
}
コード例 #2
0
ファイル: Enemy.cpp プロジェクト: joshuarobinson/solarus
/**
 * \brief When the enemy is killed, returns whether the dying animation is finished.
 * \return true if the dying animation is finished
 */
bool Enemy::is_dying_animation_finished() const {

  if (!is_dying()) {
    // The enemy is still alive.
    return false;
  }

  if (nb_explosions > 0) {
    // The dying animation is some explosions.
    return !exploding;
  }

  if (has_sprite()) {
    // The dying animation is the usual "enemy_killed" sprite.
    return get_sprite().is_animation_finished();
  }

  // There is no dying animation (case of holes, water and lava for now).
  return true;
}