Game Development Community

button sound

by David Maxwell · in Torque Game Engine · 07/22/2009 (2:17 am) · 5 replies

All i want is a button on the main menu to play sound

looking at the forum I see default profile is needed

It says it is in the client folder but it seems to be in common folder

any help

#1
07/22/2009 (2:38 am)
Inside "~/scripts/client/ui/defaultGameprofiles.cs" you will find this line:
// Override base controls
GuiButtonProfile.soundButtonOver = "AudioButtonOver";
What that does is attach sound "AudioButtonOver" to the .soundButtonOver field for all GuiButtonProfiles. Things added in the "game" package override/supersede those in the common package.

You will need a valid datablock (AudioProfile) in order to use it. You can also assign a .soundButtonDown to play another sound once you click on it.
GuiButtonProfile.soundButtonOver = "AudioButtonOver";
GuiButtonProfile.soundButtonDown = "AudioButtonDown";

Put your sound profiles in "~/scripts/client/audioProfiles". Sounds designated in there are loaded at startup, all other sounds are loaded as part of server creation, so make sure you place them in correct location otherwise you won't hear anything.
new AudioProfile(AudioButtonOver)
{
    filename = "art/sound/gui/buttonOver";
    description = "AudioGui";
    preload = false;
};

new AudioProfile(AudioButtonDown)
{
    filename = "art/sound/gui/buttonDown";
    description = "Audiogui";
    preload = false;
};
I'll leave it to you to find/use suitable sounds and to correct the filename/filepath.
#2
07/22/2009 (2:44 am)
thanks
#3
07/22/2009 (2:46 am)
I noticed I have not got a default Game profiles .cs file in client.
can I just create the folder?
#4
07/22/2009 (9:17 am)
And here I thought that all of the demos and starter kits had that file... Just find where all of the gui files are located, add a defaultGameProfiles.cs there and make sure it get's exec'd right before the gui files do.
#5
07/24/2009 (6:09 am)
thanks