Stopping the audio
by Marc Harroche · in Torque Game Engine · 10/09/2004 (9:27 pm) · 1 replies
Hi everyone! I just bought the book a few days ago and i'm trying to add music to the splash screen of the emaga5 game (which is working fine). I'm using the code from chapter 19-20 which I took from the koob scripts.... basically this is what the top of my control/client/client.cs looks like
new AudioDescription(AudioMusic)
{
volume = 0.8;
isLooping= false;
is3D = false;
type = $MusicAudioType;
};
new AudioProfile(AudioIntroMusicProfile)
{
filename = "~/data/sound/Song.wav";
description = "AudioMusic";
preload = true;
};
function PlayMusic(%handle)
{
if (!alxIsPlaying(%handle))
alxPlay(%handle);
}
function StopMusic(%handle)
{
if (alxIsPlaying(%handle))
alxStop(%handle);
Echo("INSIDE STOP MUSIC FUNCTION");
}
function LaunchGame()
{
Echo("STOPPING MUSIC");
StopMusic(AudioIntroMusicProfile);
createServer("SinglePlayer", "control/data/maps/book_ch5.mis");
%conn = new GameConnection(ServerConnection);
%conn.setConnectArgs("Reader");
%conn.connectLocal();
}
function ShowMenuScreen()
{
// start up the client with the menu...
PlayMusic(AudioIntroMusicProfile);
Canvas.setContent(MenuScreen);
Canvas.setCursor("DefaultCursor");
}
...... etc..
the song plays fine, but when I click on the Launch Game button, the music doesn't stop, although the concole log does output that the stopmusic function has been run..... am I missing anything?
Thanks in advance for your time.
new AudioDescription(AudioMusic)
{
volume = 0.8;
isLooping= false;
is3D = false;
type = $MusicAudioType;
};
new AudioProfile(AudioIntroMusicProfile)
{
filename = "~/data/sound/Song.wav";
description = "AudioMusic";
preload = true;
};
function PlayMusic(%handle)
{
if (!alxIsPlaying(%handle))
alxPlay(%handle);
}
function StopMusic(%handle)
{
if (alxIsPlaying(%handle))
alxStop(%handle);
Echo("INSIDE STOP MUSIC FUNCTION");
}
function LaunchGame()
{
Echo("STOPPING MUSIC");
StopMusic(AudioIntroMusicProfile);
createServer("SinglePlayer", "control/data/maps/book_ch5.mis");
%conn = new GameConnection(ServerConnection);
%conn.setConnectArgs("Reader");
%conn.connectLocal();
}
function ShowMenuScreen()
{
// start up the client with the menu...
PlayMusic(AudioIntroMusicProfile);
Canvas.setContent(MenuScreen);
Canvas.setCursor("DefaultCursor");
}
...... etc..
the song plays fine, but when I click on the Launch Game button, the music doesn't stop, although the concole log does output that the stopmusic function has been run..... am I missing anything?
Thanks in advance for your time.
Torque Owner Marc Harroche
if I put:
PlayMusic(AudioIntroMusicProfile);
StopMusic(AudioIntroMusicProfile);
The music still plays
and if I Echo the %handle inside the play/stop functions, the handle is always AudioIntroMusicProfile for both,...
Is there something wrong in my StopMusic function maybe?