diff --git a/src/items/bowling.cpp b/src/items/bowling.cpp index fe9fca306..bb1817a91 100644 --- a/src/items/bowling.cpp +++ b/src/items/bowling.cpp @@ -18,6 +18,8 @@ #include "items/bowling.hpp" +#include "audio/sfx_base.hpp" +#include "audio/sfx_manager.hpp" #include "graphics/hit_sfx.hpp" #include "graphics/material.hpp" #include "io/xml_node.hpp" @@ -74,8 +76,22 @@ Bowling::Bowling(AbstractKart *kart) // should not live forever, auto-destruct after 20 seconds m_max_lifespan = 20; + m_roll_sfx = sfx_manager->createSoundSource("bowling_roll"); + m_roll_sfx->play(); + m_roll_sfx->setLoop(true); + } // Bowling +// ---------------------------------------------------------------------------- +/** Destructor, removes any playing sfx. + */ +Bowling::~Bowling() +{ + if(m_roll_sfx->getStatus()==SFXManager::SFX_PLAYING) + m_roll_sfx->stop(); + sfx_manager->deleteSFX(m_roll_sfx); +} // ~RubberBall + // ----------------------------------------------------------------------------- /** Initialises this object with data from the power.xml file. * \param node XML Node @@ -200,6 +216,10 @@ bool Bowling::updateAndDelete(float dt) hit(NULL); return true; } + + if (m_roll_sfx->getStatus()==SFXManager::SFX_PLAYING) + m_roll_sfx->position(getXYZ()); + return false; } // updateAndDelete // ----------------------------------------------------------------------------- diff --git a/src/items/bowling.hpp b/src/items/bowling.hpp index 9841ee0f7..f8ef002c6 100644 --- a/src/items/bowling.hpp +++ b/src/items/bowling.hpp @@ -29,6 +29,7 @@ using namespace irr; #include "items/flyable.hpp" class XMLNode; +class SFXBase; /** * \ingroup items @@ -45,8 +46,12 @@ private: * kart was hit. */ bool m_has_hit_kart; + /** A sound effect for rolling ball. */ + SFXBase *m_roll_sfx; + public: - Bowling(AbstractKart* kart); + Bowling(AbstractKart* kart); + virtual ~Bowling(); static void init(const XMLNode &node, scene::IMesh *bowling); virtual bool updateAndDelete(float dt); virtual const core::stringw getHitString(const AbstractKart *kart) const; diff --git a/src/items/powerup.cpp b/src/items/powerup.cpp index 1f02d270d..6681848a0 100644 --- a/src/items/powerup.cpp +++ b/src/items/powerup.cpp @@ -152,7 +152,7 @@ void Powerup::set(PowerupManager::PowerupType type, int n) break ; case PowerupManager::POWERUP_BOWLING: - m_sound_use = sfx_manager->createSoundSource("bowling_roll"); + m_sound_use = sfx_manager->createSoundSource("bowling_shoot"); break ; case PowerupManager::POWERUP_ANVIL: