O'Reilly logo

3D Game Development with Microsoft Silverlight 3 Beginner's Guide by Gastón C. Hillar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action—generating sounds associated to game events

Now, it is time to add concurrent sound effects associated to game events.

  1. Stay in the 3DInvadersSilverlight project.
  2. Open InvadersGame.cs.
  3. Add the following private variable to hold the SoundManager instance:
    private SoundManager _soundManager;
    
  4. Add the following private method to create and initialize the sound manger related to the game:
    private void InitializeSoundManager()
    {
    _soundManager = new SoundManager(_mainPage.LayoutRoot);
    _soundManager.Volume = 1;
    }
    
  5. Add the following lines of code after the line base.Initialize(); in the Initialize method:
    InitializeSoundManager();
    
  6. Now, add the following lines of code before the end of the UpdateWithTime method (a random thunder):
    if (_random.Next(20) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required