Timer Help: Setting Indivual Timers To Sprites In An Array
What I have:
Code:
var glideShootingTimer:Timer = new Timer (500);
glideShootingTimer.start();
glideShootingTimer.addEventListener(TimerEvent.TIMER, glideShoot);
function glideShoot(evt:Event)
{
for (var g:Number = 0; g<glideArray.length; g++)
{
if (glideArray[g]._shoot == true)
{
//create new instance of torpedo
var newTorpedo = new EnemyTorpedo();
//set the torpedo's X and Y properties
newTorpedo.x = glideArray[g].x;
newTorpedo.y = glideArray[g].y;
//set the rotation, and give it a property, so we can animate it correctly
newTorpedo.rotation = newTorpedo._rot = glideArray[g].rotation;
//stuff it into the array
torpedoArray.push(newTorpedo);
//put it on the stage
addChild(newTorpedo);
//put it on index just under glide that shot it
setChildIndex(newTorpedo, getChildIndex(glideArray[g]) - 1);
}
}
}
What it does:
Every half second create a torpedo underneath every "glide" sprite on the stage.
What is wrong:
Every "glide" fires at the same time as the others.
What I need:
A way to individually time the firing. A way to make it fire in independent half second intervals, not all at once.
Help is appreciated! Thanks!