Game Development Community

??Newbie??

by Robert Carroll · in Torque Game Builder · 10/09/2009 (1:18 am) · 5 replies

Hi, I have a question Ive been doing some behaviors and just learned how to put sound in so heres what I have.
=============================================================================
=============================================================================
function MouseClickSoundBehavior::onMouseDown(%this, %modifier, %worldPos)
{ //if ($currentMenu != %this.menuID) return;
if ( isobject(%this.sound) )
alxPlay( %this.sound );
}
=============================================================================
Can annyone pls pls pls help me make the sound repedative like a machine gun?

#2
10/09/2009 (2:24 am)
Ya this one is different I found out that alxplay dosn't work on that behavior.
#3
10/09/2009 (3:20 am)
To be honest, you're pretty much going to have to copy the behavior in your other thread. It will repeat the sound if you apply the change I mentioned there, too.
function MouseClickSoundBehavior::onMouseDown( %this, %modifier, %worldPos )
{
  %this.fire( 1 );
}

function MouseClickSoundBehavior::onMouseUp( %this, %modifier, %worldPos )
{
  %this.fire( 0 );
}


function MouseClickSoundBehavior::fire( %this, %val )
{
  if( %val == 0 )
  {
    cancel( %this.fireSchedule );
    return;
  }

  alxPlay( %this.sound );

  if( !isEventPending( %this.fireSchedule ) )
    %this.fireSchedule = %this.schedule( 200, "fire", 1 );
}
WARNING! I didn't actually test this code.
#4
10/09/2009 (1:00 pm)
I just found out that I cant get the sound working with my mouse shoots behavior I don't know why because it works with the other behavior. And thanks for actually putting a code thats my first codded reply :)
#5
10/09/2009 (1:01 pm)
I'll have to mess around with it later and find out why.