Game Development Reference
In-Depth Information
if (_count < 0)
{
_count = 3;
_soundManager.PlaySound("effect");
}
}
}
Load it in the normal way and make sure it's the default state being run. Every
3 seconds it will play the first sound effect. Feel free to change the numbers
around or play both effects at once.
This code snippet plays both sounds at the same time, demonstrating that the
SoundManager uses hardware channels correctly.
public void Update(double elapsedTime)
{
_count -= elapsedTime;
if (_count < 0)
{
_count = 3;
_soundManager.PlaySound("effect");
_soundManager.PlaySound("effect2");
}
}
The SoundManager class needs a few final functions to make it more complete.
It needs to be able test if a sound is playing and also to stop a sound. Volume
control would also be useful.
public bool IsSoundPlaying(Sound sound)
{
return IsChannelPlaying(sound.Channel);
}
public void StopSound(Sound sound)
{
if (sound.Channel == -1)
{
return;
}
Al.alSourceStop(sound.Channel);
}
Search WWH ::




Custom Search