From babe9b0023ed048236b531eee9b86cce4711ec03 Mon Sep 17 00:00:00 2001 From: Deve Date: Thu, 25 Sep 2014 19:57:35 +0200 Subject: [PATCH] Fixed issue with sound which was starting in a loop --- src/karts/controller/player_controller.cpp | 12 ++++++++++-- src/karts/controller/player_controller.hpp | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/karts/controller/player_controller.cpp b/src/karts/controller/player_controller.cpp index a88a4e691..61298f308 100644 --- a/src/karts/controller/player_controller.cpp +++ b/src/karts/controller/player_controller.cpp @@ -92,6 +92,7 @@ void PlayerController::reset() m_prev_brake = 0; m_prev_accel = 0; m_prev_nitro = false; + m_sound_schedule = false; m_penalty_time = 0; } // reset @@ -108,6 +109,7 @@ void PlayerController::resetInputState() m_prev_brake = 0; m_prev_accel = 0; m_prev_nitro = false; + m_sound_schedule = false; m_controls->reset(); } // resetInputState @@ -378,14 +380,20 @@ void PlayerController::update(float dt) // Only accept rescue if there is no kart animation is already playing // (e.g. if an explosion happens, wait till the explosion is over before // starting any other animation). - if ( m_controls->m_rescue && !m_kart->getKartAnimation() ) + if (m_controls->m_rescue && !m_kart->getKartAnimation()) { new RescueAnimation(m_kart); m_controls->m_rescue=false; } - if (m_kart->getKartAnimation() && + + if (m_kart->getKartAnimation() && m_sound_schedule == false && m_kart->getAttachment()->getType() != Attachment::ATTACH_TINYTUX) { + m_sound_schedule = true; + } + else if (!m_kart->getKartAnimation() && m_sound_schedule == true) + { + m_sound_schedule = false; m_bzzt_sound->play(); } } // update diff --git a/src/karts/controller/player_controller.hpp b/src/karts/controller/player_controller.hpp index 1e75ac8e5..9f90da39b 100644 --- a/src/karts/controller/player_controller.hpp +++ b/src/karts/controller/player_controller.hpp @@ -40,6 +40,7 @@ private: int m_prev_accel; bool m_prev_brake; bool m_prev_nitro; + bool m_sound_schedule; float m_penalty_time;