Game Development Community

How to pause a sound?

by John Bura · in Torque X 2D · 07/02/2010 (9:04 pm) · 1 replies

Alright, so Im trying to pause my game, I can successfully pause the game. But the sound keeps going. Im not sure what to do.

Here is how I pause the game.
Game.Instance.Engine.GameTimeScale = 0f;

And here is how I play my sound.
Game.Instance.SoundGroup.PlaySound("Orange Level");

I have tried to go though most of the options for the .SoundGroup, but I can't seem to get one that works. Has anybody successfully paused the sound?

#1
07/04/2010 (10:33 am)
You need to use a soundcue to pause or control a sound. declare the cue in your private fields or your public fields.

Cue myCue;
Assign the cue with your PlaySound
myCue = Game.Instance.SoundGroup.PlaySound("Orange Level");
now you can pause etc
if(myCue.IsPlaying)
   myCue.Pause();
else
   myCue.Play();

You can also use the cue to do positional sound etc.

Lookup Cue, "How to Play a sound example" etc in the VS help.