Game Development Community

How do I change the button sound...

by Barry Mesa · in Torque Game Engine · 11/30/2002 (12:15 am) · 9 replies

I have read just about every post I could find here about changing the default button sounds. I know you can do it by changing the name of your sound to the default one that comes with the example, but how do you make each button sound different. I guess what I am asking is where and how do I do this. I was kind of curious if I could make a script to do this or if I had to go back and actually edit some .cc or .h code somewhere? I have tried adding a dynamic field with the gui editor soundButtonOver = ""; <-but I am guessin this is wrong. I have done this in the new example as well as the old. Real noob here can someone help?

I have also found this in the documentation.

GuiControlProfile (engine/gui/guiTypes.*)
The GuiControlProfile class instances maintain common instance data across a set of controls. Common information such as font face, colors, bitmaps and sound data are all stored in instances of GuiControlProfile, so that they don't need to be replicated on each control.

#1
12/01/2002 (6:44 am)
From memory: in client/scripts/audioprofiles.cs you should define these sounds:
new AudioProfile(AudioButtonOver)
{
   filename = "~/data/sound/gui/ButtonOver.wav";
   description = "AudioGui";
   preload = true;
};

 new AudioProfile(AudioButtonDown)
{
   filename = "~/data/sound/gui/ButtonHit.wav";
   description = "AudioGui";
   preload = true;
};

Ind defaultgameprofiles.cs, I believe these should already be in there, at the top. If not, add them.
//-----------------------------------------------------------------------------
// Override base controls
GuiButtonProfile.soundButtonOver = "AudioButtonOver";
GuiButtonProfile.soundButtonDown = "AudioButtonDown";

--Eric
#2
12/03/2002 (1:30 pm)
Ok cool thanks. That works, but what if you want to do it for specifice buttons. Like one sound to "Start Mission:, one for "Options", and so on. Where is the soundButtonOver defined? I think I would need to define the individual buttons there first then define them in the audioprofiles, and daultgameprofiles, right?

Big, big help though really. I think this is a push in the right direction.

Thanks again
Barry
#3
12/09/2002 (7:50 am)
Brry... check out the gui editor tutorial here...

www.gug.ca/members/tourniquet

as a matter of fact, check em all out quite usefull.

They were done by Devon Ly, one of the members here.

--Mike
#4
01/07/2003 (1:05 pm)
Ok I def will do that thanks for the information.
#5
08/30/2007 (7:46 am)
I'm also interested in having different sounds for different buttons. I've tried the link from above, BUT it's a broken link.

I basically want to perform this procedure in Torque Script. If need be, I'll change it inside of the SDK.

Anyone who knows a link that has any info on different sounds for different buttons. Please link me.
#6
08/30/2007 (8:24 am)
Look above at Eric Forhan answer. That is basic how you do it.
#7
08/30/2007 (10:19 am)
Yes Eric's code works, IF, I want my buttons to sound the same.

Here's what I want to do.

I have 2 buttons. One is a police station and the other is a school house.
When the player mouse over the police station a siren sounds, then if the player mouse over the school house, a bell ringing sound will be triggered.

I've used Eric's method

GuiButtonProfile.soundButtonOver = "Siren";


It works, BUT it gives the same sound for the police station & school.

I've also tried
//---------------------------------------------------------------------------------
function FirehouseButton::onMouseEnter(%this)
{
echo("on mouse enter");
alxStop($SoundPlaying);
$SoundPlaying = alxPlay(Siren);
}
//---------------------------------------------------------------------------------
which doesn't work.

and this....
//---------------------------------------------------------------------------------

FirehouseButton.soundButtonOver = "Siren";

which also doesn't work.
//---------------------------------------------------------------------------------


very confused about this issue.
please help
#8
12/20/2008 (7:09 pm)
I'm bumping this because I'd like to know the answer as well.
#9
12/20/2008 (8:08 pm)
Can't you just create a different profile, and then assign that to the button?