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);
}
============================
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);
}
About the author
Stay Up all night playing PS3 ;) add me PSN: RCBASEBALL13.
Associate William Lee Sims
Machine Code Games