Don't start rain sound too early

This commit is contained in:
Deve 2014-08-30 18:23:59 +02:00
parent d8f61e336e
commit 507d9566a0
4 changed files with 22 additions and 6 deletions

View File

@ -31,12 +31,6 @@ Rain::Rain()
m_thunder_sound = sfx_manager->createSoundSource("thunder");
m_rain_sound = sfx_manager->createSoundSource("rain");
if (m_rain_sound)
{
m_rain_sound->setLoop(true);
m_rain_sound->play();
}
RandomGenerator g;
m_next_lightning = (float)g.get(35);
} // Rain
@ -71,3 +65,14 @@ void Rain::update(float dt)
m_next_lightning = 35 + (float)g.get(35);
}
} // update
// ----------------------------------------------------------------------------
void Rain::playSound()
{
if (m_rain_sound)
{
m_rain_sound->setLoop(true);
m_rain_sound->play();
}
}

View File

@ -32,6 +32,7 @@ public:
virtual ~Rain();
void update(float dt);
void playSound();
};
#endif

View File

@ -348,6 +348,9 @@ public:
void setNetworkWorld(bool is_networked) { m_is_network_world = is_networked; }
bool isNetworkWorld() const { return m_is_network_world; }
/** Returns a pointer to the rain. */
Rain* getRain() {return m_rain;}
}; // World
#endif

View File

@ -130,10 +130,17 @@ void WorldStatus::update(const float dt)
case SETUP_PHASE:
m_auxiliary_timer = 0.0f;
m_phase = TRACK_INTRO_PHASE;
if (m_play_racestart_sounds)
{
m_track_intro_sound->play();
}
if (World::getWorld()->getRain() != NULL)
{
World::getWorld()->getRain()->playSound();
}
return;
case TRACK_INTRO_PHASE:
m_auxiliary_timer += dt;