Mouse Events
by Daniel Thornton · in Torque Game Engine · 09/07/2005 (9:02 am) · 2 replies
Ok, the torque script reference links won't work and can't find anything in the forums, or don't have access to threads that look like they might help. Mouse events have been confusing me. Honestly, I can't tell where in the scripts a right mouse click triggers a weapon fire, or any other mouse events. I'm trying to get sounds triggered in the guiMainMenu by the mouse and different keyboard keys. No need for buttons to trigger, just a basic on right mouse click this sound is played, on left mouse click this other sound is played. If I have to fake it by putting a big button over the whole gui thats fine, and if it would work out better in game thats fine too. Anybody that can help or point me to help about mouse events and how to use them?
thanks
thanks
About the author
#2
09/07/2005 (11:37 am)
Thanks for the details. I wasn't aware of action maps, but glad to hear it. If anyone has info on how they work I'll take it. looking around about it now, thanks again.
Torque Owner Mark Storer
Ah!
You need to add something like the following to your actionMap:
You'll also need to define the functions "playASound" and "playADifferentSound". Something Like This:
$sound1Handle = alxCreateSource("AudioCloseLooping3d", expandFilename("~/data/sound/sound1.wav")); $sound2Handle = alxCreateSource("AudioCloseLooping3d", expandFilename("~/data/sound/sound2.wav")); function playASound( %down) { if (%down) { if (!alxIsPlaying( $sound1Handle )) { alxPlay( $sound1Handle ); } } else { alxStop( $sound1Handle ); } } function playADifferentSound() { if (%down) { if (!alxIsPlaying( $sound2Handle )) { alxPlay( $sound1Handle ); } } else { alxStop( $sound2Handle ); } }Note: Other than the "bind" stuff, I haven't done any of this myself, I'm just swiping stuff from the private forums.
Ah... and here's something else. In addition to the alx stuff (which could create client-only sounds), you can also do things over the network from the server. Here's a sample of someone playing a sound when a person enters a trigger:
datablock TriggerData(WickwardTrigger) { tickPeriodMS = 100; }; function WickwardTrigger::onEnterTrigger( %this, %trigger, %obj ) { serverPlay3D(Wickwardnoise,%obj.getTransform()); } //---------------------------------------------------------------------------- // Wickwardnoise - jwoods //---------------------------------------------------------------------------- datablock AudioProfile(Wickwardnoise) { filename = "~/data/sound/wierd.wav"; description = AudioClose3d; preload = false; };So the wickward trigger is tested 10 times a second (tickPeriodMS = 100). When it goes off, it plays the wickWardNoise for everyone close enough to hear an "audioClose3d" sound.
Hope that helps.