/** * \brief Starts (or restarts) the "sword" animation of the hero's sprites. */ void HeroSprites::set_animation_sword() { int direction = get_animation_direction(); tunic_sprite->set_current_animation("sword"); tunic_sprite->restart_animation(); sword_sprite->set_current_animation("sword"); sword_sprite->set_current_direction(direction); sword_sprite->restart_animation(); sword_stars_sprite->stop_animation(); if (equipment.has_ability("shield")) { if (direction % 2 != 0) { shield_sprite->set_current_animation("sword"); shield_sprite->set_current_direction(direction / 2); shield_sprite->restart_animation(); } else { stop_displaying_shield(); } } stop_displaying_trail(); }
/** * \brief Starts the "hurt" animation of the hero's sprites. */ void HeroSprites::set_animation_hurt() { tunic_sprite->set_current_animation("hurt"); stop_displaying_sword(); stop_displaying_shield(); stop_displaying_trail(); }
/** * \brief Starts the "hurt" animation of the hero's sprites. */ void HeroSprites::set_animation_hurt() { set_tunic_animation("hurt"); stop_displaying_sword(); stop_displaying_shield(); stop_displaying_trail(); }
/** * \brief Starts the "falling" animation of the hero's sprites. */ void HeroSprites::set_animation_falling() { // show the animation tunic_sprite->set_current_animation("falling"); stop_displaying_sword(); stop_displaying_shield(); stop_displaying_trail(); }
/** * \brief Starts the "walking_diagonal" animation of the hero's sprites. * \param direction8 the diagonal direction to take (1, 3, 5 or 7) */ void HeroSprites::set_animation_walking_diagonal(int direction8) { stop_displaying_sword(); stop_displaying_shield(); stop_displaying_trail(); tunic_sprite->set_current_animation("walking_diagonal"); tunic_sprite->set_current_direction(direction8 / 2); }
/** * \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(); }
/** * \brief Starts the "stopped" animation with sprites that represent * the hero swimming. */ void HeroSprites::set_animation_stopped_swimming() { set_animation_stopped_common(); tunic_sprite->set_current_animation("swimming_stopped"); stop_displaying_sword(); stop_displaying_shield(); stop_displaying_trail(); }
/** * \brief Starts the "brandish" animation of the hero's sprites. */ void HeroSprites::set_animation_brandish() { tunic_sprite->set_current_animation("brandish"); tunic_sprite->set_current_direction(1); stop_displaying_sword(); stop_displaying_shield(); stop_displaying_trail(); }
/** * \brief Starts the "swimming_fast" animation of the sprites. */ void HeroSprites::set_animation_swimming_fast() { set_animation_walking_common(); set_tunic_animation("swimming_fast"); stop_displaying_sword(); stop_displaying_shield(); stop_displaying_trail(); }
/** * \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(); }
/** * \brief Starts the "walking" animation with sprites that represent * the hero carrying something. * * If the hero actually carries an item, the carried item also takes a "walking" animation. */ void HeroSprites::set_animation_walking_carrying() { set_animation_walking_common(); set_tunic_animation("carrying_walking"); if (lifted_item != nullptr) { lifted_item->set_animation_walking(); } stop_displaying_shield(); stop_displaying_trail(); }
/** * \brief Starts the "walking" animation with sprites that represent * the hero carrying something. * * If the hero actually carries an item, the carried item also takes a "walking" animation. */ void HeroSprites::set_animation_walking_carrying() { set_animation_walking_common(); tunic_sprite->set_current_animation("carrying_walking"); if (lifted_item != NULL) { lifted_item->set_animation_walking(); } stop_displaying_shield(); stop_displaying_trail(); }
/** * \brief Starts the "boomerang" animation of the hero's sprites. * \param tunic_preparing_animation Animation name of the hero's tunic sprite * when preparing the boomerang. */ void HeroSprites::set_animation_boomerang( const std::string& tunic_preparing_animation) { set_tunic_animation(tunic_preparing_animation); if (shield_sprite != nullptr && shield_sprite->has_animation("boomerang")) { shield_sprite->set_current_animation("boomerang"); } else { stop_displaying_shield(); } stop_displaying_sword(); stop_displaying_trail(); }
/** * \brief Starts a custom animation of the hero's sprites. * * The animation of the tunic and the shield (if any) can be specified here. * Other sprites are hidden. Many simple animations can be started with * this function. More complex one have dedicated functions. * * \param tunic_animation name of the animation to give to the tunic sprite * \param shield_animation name of the animation to give to the shield sprite, * or an empty string to hide the shield. */ void HeroSprites::set_animation(const std::string& tunic_animation, const std::string& shield_animation) { tunic_sprite->set_current_animation(tunic_animation); if (shield_animation.size() > 0 && equipment.has_ability("shield")) { shield_sprite->set_current_animation(shield_animation); } else { stop_displaying_shield(); } stop_displaying_sword(); stop_displaying_trail(); }
/** * \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(); } }
/** * \brief Starts the "pulling" animation of the hero's sprites. */ void HeroSprites::set_animation_pulling() { tunic_sprite->set_current_animation("pulling"); stop_displaying_shield(); stop_displaying_trail(); }
/** * \brief Starts the "lifting" animation of the hero's sprites. */ void HeroSprites::set_animation_lifting() { set_tunic_animation("lifting"); stop_displaying_shield(); stop_displaying_trail(); }