A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Timer Help: Setting Indivual Timers To Sprites In An Array

Threaded View

  1. #1
    Junior Member
    Join Date
    Jun 2009
    Posts
    6

    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!
    Last edited by iambubbathedog; 06-21-2009 at 12:36 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center