Time for action – building a sound effects manager
Download the
0669_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 newSounds
folder in the content project.Add a new class to the Asteroid Belt Assault project called "SoundManager".
Add
using
directives to the top of the SoundManager class file:using System.Diagnostics; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Content;
Modify the declaration of the SoundManager class by adding
public
static
before the declaration:public static class SoundManager
Declare variables for the SoundManager class:
private static List<SoundEffect> explosions = new List<SoundEffect>(); private static int explosionCount = 4; private static SoundEffect playerShot; private static SoundEffect enemyShot...