Stopping Music
by Do Not Delete · in Torque X Platformer Kit · 07/29/2007 (8:11 pm) · 8 replies
I'm using the Sound Manager that is in the PlatformerFramework project to play some music when the level loads.
What code stops the music that is currently being played?
What code stops the music that is currently being played?
About the author
#2
07/30/2007 (10:03 pm)
Sorry but I didn't understand what you just said :(
#3
07/31/2007 (3:12 pm)
The platformer starter project doesn't have music. In the platformer demo project, the music is controlled by the Game class. Look at Game.cs or CaveMusicTriggerComponent.cs.
#4
07/31/2007 (7:08 pm)
The platformer framework has a sound manager and I'm using it for starting the music right now.
#5
08/01/2007 (3:44 pm)
Well, like I said, the Game class in the demo project has exactly the code you're looking for. It has cue stopping in 3 places. I'll go ahead and paste the code here.// PlaySound returns a Cue object // you need to store a reference to the Cue object if you want to stop it: Cue mySound = SoundManager.Instance.PlaySound(mySoundGroupName, mySoundCueName); // you can stop the sound from playing by calling Stop on the Cue like so: mySound.Stop(AudioStopOptions.AsAuthored);
#6
08/01/2007 (8:25 pm)
Thanks! I'll try this right away!
#7
Here is the code:
08/01/2007 (8:28 pm)
I just tried it and the sound won't stop.Here is the code:
//Start playing music
SoundManager.Instance.RegisterSoundGroup(@"data\sound\music");
SoundManager.Instance.RegisterSoundGroup(@"data\sound\Win\Background.xsb", @"data\sound\Win\Background.xwb");
Cue mySound = SoundManager.Instance.PlaySound(@"data\sound\Win\Background.xsb", "game_music");
if (gs.Buttons.Start == ButtonState.Pressed)
{
mySound.Stop(AudioStopOptions.AsAuthored);
}
#8
08/02/2007 (2:58 pm)
That seems like it would start the music and only stop it if the button was pressed as the sound was started. You'll want to store the sound cue in a member field and stop it in a different method (ProcessTick, for example).
Torque Owner Thomas Buscaglia