
CHAPTER 7 ■ ADDING SOUNDS TO YOUR XNA 3.0 PROJECT
590
protected override void Initialize()
{
audioEngine = new AudioEngine("myXactProject.xgs");
waveBank = new WaveBank(audioEngine, "myWaveBank.xwb");
soundBank = new SoundBank(audioEngine, "mySoundBank.xsb");
base.Initialize();
}
PlaysoundsusingthesoundBank.PlayCue method, such as after a key press, as shown in
thefollowingcode.MakesureyoucalltheaudioEngine.Update method each frame:
protected override void Update(GameTime gameTime)
{
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
this.Exit();
KeyboardState keybState = Keyboard.GetState();
if (keybState.IsKeyDown(Keys.Space)) ...