Game Development Community

New Audio behaviours added.

by Saiko · in Torque Game Builder · 01/06/2008 (8:48 am) · 5 replies

Ok, as a couple of people seemed to be having trouble with onCollision sounds etc I decided to add a couple of new audio behaviours to TDN. They are PlaySoundOnRemove and PlaySoundOnCollision.

These are pretty basic and have all the usual issues with sound. Please be warned they shouldn't be considered as a solution to your audio issues they are really just basic play a sound type of behaviours. That said they'll help you get some simple sounds going.

They can be found here.

tdn.garagegames.com/wiki/TGB/Behaviors/PlaySoundOnRemove
tdn.garagegames.com/wiki/TGB/Behaviors/PlaySoundOnCollision

Suggestions and comments fire em off here. Please read the notes in the source first tho ;) Also, note too many sounds spamming your level will make your app go a bit nuts. You have been warned lol

Anyway, have fun with them and hopefully someone will find them useful.

#1
01/06/2008 (10:48 am)
Thanks a lot. The more the better. Behaviours I ment ;-)
#2
01/06/2008 (12:42 pm)
No worries - hopefully they'll be useful.
#3
01/06/2008 (12:59 pm)
Nice Saiko! These will come in handy.

Here's another from me.
tdn.garagegames.com/wiki/TGB/Behaviors/MouseClickSound
#4
01/06/2008 (2:29 pm)
Cool Joe.

If you want to add right mouse button support to that its pretty easy ...

if (!isObject(MouseClickSoundBehavior))
{
   %template = new BehaviorTemplate(MouseClickSoundBehavior);
   %template.friendlyName = "Mouse Click Sound";
   %template.behaviorType = "GUI";
   %template.description  = "Play a sound when the user clicks this object. ";
   %template.addBehaviorField(sound, "The sounds audio profile.", string ,"test"   );
   %template.addBehaviorField(useRightMouseButton, "Use right mouse button", bool, false);
} 

function MouseClickSoundBehavior::onBehaviorAdd(%this)
{ 
    %this.owner.setUseMouseEvents(true);  
}

function MouseClickSoundBehavior::onMouseUp(%this, %modifier, %worldPos)
{
    if(!%this.useRightMouseButton)
    {
        %this.playSound();
    }
}

function MouseClickSoundBehavior::onRightMouseUp(%this, %modifier, %worldPos)
{
    if(%this.useRightMouseButton)
    {
        %this.playSound();
    }
}

function MouseClickSoundBehavior::playSound(%this)
{
  if ( isobject(%this.sound) )
  {
     alxPlay( %this.sound );
  }
  else
  {
     echo( "MouseOverSoundBehavior: Invalid Audio Profile! " @  %this.sound );
  }
}
#5
08/15/2009 (12:22 pm)
Sorry for asking, but my skills on behavior coding is very limited.

Could someone create a behavior to play a sound upon stage start? So one can play music and such things.

Thanks in advance.