private void playSound_Click(object sender, RoutedEventArgs e)
 {
     var instance = sound.Play(.5f);
     if (instance != null) soundInstance = instance;
     else if (soundInstance != null) soundInstance.Play(.5f);
 }
示例#2
0
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) this.Exit();

            audio.Update();

            if (GamePad.GetState(PlayerIndex.One).Buttons.A == ButtonState.Pressed)
            {
                var instance = sound.Play(.5f);
                if (instance != null) soundInstance = instance;
                else if (soundInstance != null) soundInstance.Play(.5f);
            }

            if (GamePad.GetState(PlayerIndex.One).Buttons.X == ButtonState.Pressed)
            {
                if (soundInstance != null) soundInstance.Pause();
            }

            if (GamePad.GetState(PlayerIndex.One).Buttons.B == ButtonState.Pressed)
            {
                if (soundInstance != null) soundInstance.Stop();
            }

            base.Update(gameTime);
        }