Opening Sound
by Dwayne Brown · in Technical Issues · 06/07/2006 (4:34 pm) · 13 replies
Hello community!!!! Its been a while since I have been on the forums and I have been working on this game in which I need your help....What I want to do is to play a music file that plays at the launch of the game. When the game starts the music will end. I looked at several tutorials online and there where too much gaps in the tutorial killing the nOOb in mid way. Can someone direct me in a direction to look into.
-Thanks in advance!
-Thanks in advance!
About the author
#2
All you have to do is to add a function and init it.
06/08/2006 (3:57 pm)
It's already there in client/init.csAll you have to do is to add a function and init it.
#3
Billy are you saying that I should add that phrase in the init.cs part or do I need to create a new function in audioprofile.cs as I beleive mike is suggesting?
06/08/2006 (6:35 pm)
Ok you guys kind of lost me I am not a seasoned torgue user yet =DBilly are you saying that I should add that phrase in the init.cs part or do I need to create a new function in audioprofile.cs as I beleive mike is suggesting?
#4
function MainMenuGui::onWake(%this)
{
// Kick off an update on next tick.
if(!$pref::RSS::disableFeedCheck)
schedule(50, 0, kickOffRSS);
alxSetChannelVolume($GuiMusicAudioType,1);
$guimenumusic=alxCreateSource(MainMenuMusic);
alxPlay($guimenumusic);
}
function MainMenuGui::onSleep(%this)
{
alxSetChannelVolume($GuiMusicAudioType,0);
alxStop($guimenumusic);
}
Also - created a new sound profile in the client audio profiles script
$GuiMusicAudioType = 0;
new AudioProfile(MainMenuMusic)
{
description= AudioGuiLooping;
filename = "~/data/sound/menu.ogg"; //main menu track!
preload = false;
};
might help..
There was some fancey music playing resource - though i cant remember where - have a look, it looked
to be quite powerful - supporting many more features than the basic sound system.
goodluck
06/08/2006 (7:04 pm)
Im a torque scripting noOby myself - but i slapped this into the mainmain client script..function MainMenuGui::onWake(%this)
{
// Kick off an update on next tick.
if(!$pref::RSS::disableFeedCheck)
schedule(50, 0, kickOffRSS);
alxSetChannelVolume($GuiMusicAudioType,1);
$guimenumusic=alxCreateSource(MainMenuMusic);
alxPlay($guimenumusic);
}
function MainMenuGui::onSleep(%this)
{
alxSetChannelVolume($GuiMusicAudioType,0);
alxStop($guimenumusic);
}
Also - created a new sound profile in the client audio profiles script
$GuiMusicAudioType = 0;
new AudioProfile(MainMenuMusic)
{
description= AudioGuiLooping;
filename = "~/data/sound/menu.ogg"; //main menu track!
preload = false;
};
might help..
There was some fancey music playing resource - though i cant remember where - have a look, it looked
to be quite powerful - supporting many more features than the basic sound system.
goodluck
#5
06/08/2006 (7:11 pm)
OK I will try that because that I can see lol
#6
One way is to add it in client/missiondownload.cs under onMissionDownloadComplete().
But it really depends on when you want the music to start playing.
You need to setup a new audioprofile for the music in audioprofile.cs.
06/08/2006 (7:21 pm)
I only submitted the base call.One way is to add it in client/missiondownload.cs under onMissionDownloadComplete().
But it really depends on when you want the music to start playing.
You need to setup a new audioprofile for the music in audioprofile.cs.
#7
I didn't realise you were new. There are several ways to make what you want. I just coded mine, (works while the splash screen is showing) from the 3dagp1 book.
If you want the code, let me know.
06/08/2006 (7:58 pm)
Sorry Dwayne,I didn't realise you were new. There are several ways to make what you want. I just coded mine, (works while the splash screen is showing) from the 3dagp1 book.
If you want the code, let me know.
#8
06/09/2006 (7:04 am)
I have the 3D game programming all in one book and what page would that be on? I do not remember that being in there....
#9
-thanks
06/15/2006 (3:54 pm)
I looked inside the book and found nothing pertaining to opening music. It only shows and explains how to do music for other things like in-game music and sound effects. If you can please send me that code.-thanks
#10
10/02/2006 (6:42 am)
I think you can find this part in Chapter 20.
#11
For music playing during the splash screen, you would add the following around line 101 of client/init.cs:
At the end of client/scripts/audioProfile.cs add the following:
If you want to add background music to your game, You would add your profile to server/scripts/audioProfile.cs and call it in server/scripts/game.cs at the end of the functon:
10/02/2006 (3:39 pm)
Sorry, haven't seen this for a while.For music playing during the splash screen, you would add the following around line 101 of client/init.cs:
// Default player key bindings
exec("./scripts/default.bind.cs");
exec("./config.cs");
// Really shouldn't be starting the networking unless we are
// going to connect to a remote server, or host a multi-player
// game.
setNetPort(0);
//=============Startup music===========
alxPlay( AudioStartupProfile); /// This starts up our splash screen music. This is what you need. The rest is for reference.
//======================================
// Copy saved script prefs into C++ code.
setShadowDetailLevel( $pref::shadows );At the end of client/scripts/audioProfile.cs add the following:
new AudioDescription(AudioStartup)
{
volume = 0.8;
isLooping= false;
is3D = false;
type = $GuiAudioType;
};
new AudioProfile(AudioStartupProfile)
{
filename = "~/data/sound/YourSoundFile.wav"; //Change me to your actual sound file.
description = "AudioStartup";
preload = true;
}That should do it for you.If you want to add background music to your game, You would add your profile to server/scripts/audioProfile.cs and call it in server/scripts/game.cs at the end of the functon:
function GameConnection::onClientEnterGame(%this)Hope this helps you.
#12
and i thout i undid everything i did during this and yet im still at a standstill cant even play ...
any help would be very very very much apreciated = |
10/02/2006 (6:02 pm)
Hey I was looking to add bacround music and actually have another thread concerning this but i followed what u guys were saying and now when i go to start starter.fps -(my modded game)- it does the garage game logo then it just goes to a blank black screen instead of my main menu.and i thout i undid everything i did during this and yet im still at a standstill cant even play ...
any help would be very very very much apreciated = |
#13
10/03/2006 (6:45 am)
It is difficult to say exactly what happened, but more than likely you accidently touched something you should not have for this modification. The first thing I would do is run the game up, and when it has stopped doing anything hit the tilde key (really ' because no shift) to check out the console. See if any errors are being reported. If you are really stumped, one of the best ways to learn what might have gone wrong (in my humble opinion) is to go redownload the engine and install it to a different folder...this way you have your 'control' unmodified copy and the copy you are working on. When things go funk, you can take a program like Beyond Compare (or any differencing file program in general) and check out what is different about the files you touched and their original 'control' version.
Torque 3D Owner Billy L
To start the music use
$whatevername = alxplay(your_AudioProfile_in_the_clientside_audioprofiles.cs);
and to stop
alxstop($whatevername);