diff --git a/src/karts/kart_model.cpp b/src/karts/kart_model.cpp index d78f096f8..8f78041da 100644 --- a/src/karts/kart_model.cpp +++ b/src/karts/kart_model.cpp @@ -138,6 +138,7 @@ KartModel::KartModel(bool is_master) m_animation_frame[i]=-1; m_animation_speed = 25; m_current_animation = AF_DEFAULT; + m_play_non_loop = false; } // KartModel // ---------------------------------------------------------------------------- @@ -682,11 +683,12 @@ void KartModel::finishedRace() /** Enables- or disables the end animation. * \param type The type of animation to play. */ -void KartModel::setAnimation(AnimationFrameType type) +void KartModel::setAnimation(AnimationFrameType type, bool play_non_loop) { // if animations disabled, give up if (m_animated_node == NULL) return; + m_play_non_loop = play_non_loop; m_current_animation = type; if(m_current_animation==AF_DEFAULT) { @@ -825,6 +827,12 @@ void KartModel::update(float dt, float distance, float steer, float speed) // If animations are disabled, stop here if (m_animated_node == NULL) return; + if (m_play_non_loop && m_animated_node->getLoopMode() == true) + { + m_play_non_loop = false; + this->setAnimation(AF_DEFAULT); + } + // Update the speed-weighted objects' animations if (m_kart != NULL) { diff --git a/src/karts/kart_model.hpp b/src/karts/kart_model.hpp index 6b063e4eb..6180cb89a 100644 --- a/src/karts/kart_model.hpp +++ b/src/karts/kart_model.hpp @@ -207,9 +207,14 @@ private: /** True if this is the master copy, managed by KartProperties. This * is mainly used for debugging, e.g. the master copies might not have - * anything attached to it etc. */ + * anything attached to it etc. */ bool m_is_master; + /** True if the animation played is non-loop, which will reset to + * AF_DEFAULT after first loop ends. Mainly used in soccer mode for + * animation playing after scored. */ + bool m_play_non_loop; + void loadWheelInfo(const XMLNode &node, const std::string &wheel_name, int index); @@ -306,7 +311,7 @@ public: AnimationFrameType getAnimation() { return m_current_animation; } // ------------------------------------------------------------------------ /** Enables- or disables the end animation. */ - void setAnimation(AnimationFrameType type); + void setAnimation(AnimationFrameType type, bool play_non_loop = false); // ------------------------------------------------------------------------ /** Sets the kart this model is currently used for */ void setKart(AbstractKart* k) { m_kart = k; } diff --git a/src/modes/soccer_world.cpp b/src/modes/soccer_world.cpp index f6d99ee02..7609ddcb9 100644 --- a/src/modes/soccer_world.cpp +++ b/src/modes/soccer_world.cpp @@ -93,8 +93,6 @@ void SoccerWorld::reset() } else WorldStatus::setClockMode(CLOCK_CHRONO); - m_animation_timer = 0.0f; - m_animation_showing_kart = -1; m_can_score_points = true; m_red_goal = 0; m_blue_goal = 0; @@ -164,17 +162,6 @@ void SoccerWorld::update(float dt) } } - if (!(isRaceOver() || isStartPhase()) && m_animation_showing_kart != -1) - { - m_animation_timer += dt; - if (m_animation_timer > 6.0f) - { - m_karts[m_animation_showing_kart] - ->getKartModel()->setAnimation(KartModel::AF_BEGIN); - m_animation_timer = 0.0f; - m_animation_showing_kart = -1; - } - } } // update //----------------------------------------------------------------------------- @@ -192,7 +179,6 @@ void SoccerWorld::onCheckGoalTriggered(bool first_goal) m_goal_sound->play(); if (m_ball_hitter != -1) { - m_animation_showing_kart = m_ball_hitter; ScorerData sd; sd.m_id = m_ball_hitter; sd.m_correct_goal = isCorrectGoal(m_ball_hitter, first_goal); @@ -200,7 +186,13 @@ void SoccerWorld::onCheckGoalTriggered(bool first_goal) if (sd.m_correct_goal) { m_karts[m_ball_hitter]->getKartModel() - ->setAnimation(KartModel::AF_WIN_START); + ->setAnimation(KartModel::AF_WIN_START, true/* play_non_loop*/); + } + + else if (!sd.m_correct_goal) + { + m_karts[m_ball_hitter]->getKartModel() + ->setAnimation(KartModel::AF_LOSE_START, true/* play_non_loop*/); } if (first_goal) diff --git a/src/modes/soccer_world.hpp b/src/modes/soccer_world.hpp index ba1a6cc6f..a43a8b794 100644 --- a/src/modes/soccer_world.hpp +++ b/src/modes/soccer_world.hpp @@ -66,10 +66,6 @@ private: float m_goal_timer; int m_ball_hitter; - /** Timer for win/lose animation showing after each goal*/ - float m_animation_timer; - int m_animation_showing_kart; - /** Goals data of each team scored */ int m_red_goal; int m_blue_goal;