Game Development Community

Easy

by Robert Carroll · in Torque Game Builder · 10/02/2009 (9:45 pm) · 1 replies

Ok, I have a easy "noob" question. How do I get the audio to play continuously while in MouseDown?
============================
With This Mouse Shoots Code?
============================
============================

function MouseShootsBehavior::onMouseDown(%this, %modifier, %worldPos)
{
alxPlay(Shoot);
%this.fire(1);
alxPlay(Shoot);
}

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


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

if (!isObject(%this.projectile))
return;

%projectile = %this.projectile.cloneWithBehaviors();

%projectile.setPosition(%this.owner.position);
%projectile.setRotation(%this.owner.rotation);
%projectile.setLinearVelocityPolar(%this.owner.rotation, %this.projectileSpeed);

if(%this.fireRate <= 0)
{
cancel(%this.fireSchedule);
return;
}

if (!isEventPending(%this.fireSchedule))
%this.fireSchedule = %this.schedule(%this.fireRate * 1000, "fire", 1);
}

#1
10/02/2009 (11:37 pm)
At first glance, it looks like you just need to move the "alxPlay(shoot);" outside of the if-condition. Maybe put it just before the cloneWithBehaviors call.