Game Development Community

Sound Effects On Buttons

by Tyler Pfaff · in Game Design and Creative Issues · 10/09/2004 (9:23 am) · 2 replies

I'm trying to be able to play sound effects when the mouse moves over buttons and when the mouse clicks a button. I know that I'm supposed to put the new AudioProfiles in init.cs, but where do I initialize the GuiButtonProfile's members soundButtonOver and soundButtonDown? Thanks in advance!

#1
10/09/2004 (2:30 pm)
If you use the same profile for both GuiButton and GuiBitMapButton .
add the below lines to client/ui/defaultgameprofiles.cs
GuiButtonProfile.soundButtonOver = "AudioButtonOver";
GuiButtonProfile.soundButtonDown = "AudioButtonDown";
If you use another profile then GuiButtonProfile to your buttons you must add the above lines to that profile.
And change GuiButtonProfile to yourOtherProfile :) !!



And in
client/audioprofiles.cs add
new AudioProfile(AudioButtonOver)
{
    filename "path to soundfile";
    description = "AudioGui";
    preload = true;
}



new AudioProfile(AudioButtonDown)
{
    filename "path to soundfile";
    description = "AudioGui";
    preload = true;
}

if you want a buttonup sound you must change the guiButtonBaseCtrl.cc and
add some new lines to onMouseup.
#2
10/12/2004 (7:11 am)
Thanks, Billy. It works like a charm.