Exemplo n.º 1
0
/**
 * \brief Stops displaying the sword and the sword stars (if any).
 */
void HeroSprites::stop_displaying_sword() {

  if (is_sword_visible()) {
    sword_sprite->stop_animation();
  }
  stop_displaying_sword_stars();
}
Exemplo n.º 2
0
/**
 * \brief Starts (or restarts) the "super_spin_attck" animation of the hero's sprites.
 */
void HeroSprites::set_animation_super_spin_attack() {

  tunic_sprite->set_current_animation("super_spin_attack");
  sword_sprite->set_current_animation("super_spin_attack");
  stop_displaying_sword_stars();
  stop_displaying_shield();
  stop_displaying_trail();
}
Exemplo n.º 3
0
/**
 * \brief Starts the "victory" animation of the hero's sprites.
 */
void HeroSprites::set_animation_victory() {

  tunic_sprite->set_current_animation("victory");
  tunic_sprite->set_current_direction(1);
  if (sword_sprite != NULL) {
    sword_sprite->set_current_animation("victory");
    sword_sprite->set_current_direction(1);
  }
  stop_displaying_sword_stars();
  stop_displaying_shield();
  stop_displaying_trail();
}
Exemplo n.º 4
0
/**
 * \brief Starts a custom animation of the hero's sprites.
 *
 * All sprites of the hero that have an animation with this name take the
 * animation. The ones that don't have such an animation are not displayed.
 * Many simple animations can be started with this function.
 * More complex one have dedicated functions.
 *
 * \param animation Name of the animation to give to the hero's sprites.
 * \param callback_ref Lua ref of a function to call when the animation ends
 * or an empty ref.
 */
void HeroSprites::set_animation(
    const std::string& animation,
    const ScopedLuaRef& callback_ref
) {

  if (tunic_sprite->has_animation(animation)) {
    set_tunic_animation(animation, callback_ref);
  }
  else {
    Debug::error("Sprite '" + tunic_sprite->get_animation_set_id() + "': Animation '" + animation + "' not found.");
  }

  if (shield_sprite != nullptr
      && shield_sprite->has_animation(animation)) {
    shield_sprite->set_current_animation(animation);
  }
  else {
    stop_displaying_shield();
  }

  if (sword_sprite != nullptr
      && sword_sprite->has_animation(animation)) {
    sword_sprite->set_current_animation(animation);
  }
  else {
    stop_displaying_sword();
  }

  if (sword_stars_sprite != nullptr
      && sword_stars_sprite->has_animation(animation)) {
    sword_stars_sprite->set_current_animation(animation);
  }
  else {
    stop_displaying_sword_stars();
  }

  if (trail_sprite != nullptr
      && trail_sprite->has_animation(animation)) {
    trail_sprite->set_current_animation(animation);
  }
  else {
    stop_displaying_trail();
  }
}
Exemplo n.º 5
0
/**
 * \brief Starts the "running" animation of the hero's sprites.
 */
void HeroSprites::set_animation_running() {

  set_animation_walking_sword_loading();
  stop_displaying_sword_stars();
  trail_sprite->set_current_animation("running");
}