Time for action – building a sound effects manager
Download the
2403_05_AUDIOPACK.zip
file from the book's website and extract the files to a temporary folder.Right-click on the content project in Solution Explorer and add a new folder called Sounds.
Add the
.WAV
files from the audio pack temporary folder to your new Sounds folder in the content project.Add a new module (not a class this time) to the Asteroid Belt Assault project called SoundManager by right-clicking on the project name in Solution Explorer and selecting Add | Module.
Declare variables for the SoundManager module:
Private explosions As List(Of SoundEffect) = new List(Of SoundEffect)() Private explosionCount As Integer = 4 Private playerShot As SoundEffect Private enemyShot As SoundEffect Private rand As Random = new Random()
Add the
Initialize()
method to theSoundManager
class:Public Sub Initialize(content As ContentManager) Try playerShot = content.Load(Of SoundEffect)("Sounds\Shot1") enemyShot ...