Interface Sounds


Torque has a mechanism built in to offer sound effects when you use buttons. Objects that use the GuiDefaultProfile profile have two sound effects available: soundButtonDown and soundButtonOver.

If you look in C:\koob\control\ client\default_profiles, you will find a sound effect for the buttonover context that I've created. This sound occurs whenever the cursor passes over a GUI button that has been defined to use the GuiDefaultProfile. The line looks like this:

 GuiButtonProfile.soundButtonOver = "AudioButtonOver"; 

It points the property to an AudioProfile. The profile is located in C:\koob\control\client\initialize.cs. The profile is located there and not in the sndprofiles.cs module because I need it to load before the menu with the buttons comes up. The AudioButtonOver profile looks like this:

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

It's pretty straightforward. A useful exercise for you at this point would be to create a sound effect for pressing down on the button, insert the appropriate audio profile code, and then point the soundButtonDown property at it, just as I showed you for the soundButtonOver property.




3D Game Programming All in One
3D Game Programming All in One (Course Technology PTR Game Development Series)
ISBN: 159200136X
EAN: 2147483647
Year: 2006
Pages: 197

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net