Time for action – building the SFXManager class
In order to build the
SFXManager
class, perform these steps:
1. Download the
7089_10_AUDIOPACK.zip
file from the book's website and extract the contents to a temporary location.2. Copy the
Sounds
folder from the audio pack to the clipboard.3. In Visual Studio, select the content project in Solution Explorer, right-click and select Paste.
4. Create a new class file called
SFXManager.cs
in theMars Runner
project.5. Add the
using
directive to the beginning of theSFXManager
class file as follows:using Microsoft.Xna.Framework.Audio;
6. Modify the declaration of the
SFXManager
class to mark it as static. The declaration should now read as follows:static class SFXManager
7. Add a
Dictionary
object to theSFXManager
class to store sound effects:#region Fields private static Dictionary<string, SoundEffect> soundEffects = new Dictionary<string, SoundEffect>(); #endregion
8. Add the
AddEffect()
method to theSFXManager
class:#region Initialization...