samedi 27 juin 2015

Use the same array to next frame

Im making a game and i complete the level1 at frame1. When im trying to make the level2 to frame2 i dont know how to transfer my Arrays to frame2.All the other buttons and functions are working(i copy the eventListeners to frame2)but my enemies wich are in Arrays does nothing!! Thanks a lot!!! import flash.events.Event;

stop();
//variables the helicopters
var enemy1Array:Array = new Array();
    for (var e1:int = numChildren - 1; e1 >= 0; e1--) 
    {
        var child:DisplayObject = getChildAt(e1);
        if (child.name == "enemy1") 
        {
          enemy1Array.push(child);
        }
    }

stage.addEventListener(Event.ENTER_FRAME, allloop);
function allloop(event:Event):void
{
//move the helicopters
for each(var enemy1:Sprite in enemy1Array)
{
   enemy1.x = enemy1.x -= enemy1speed;
   if(enemy1.hitTestObject(defense))
   {
            addChild(explotionbonus3);
            explotionbonus3.gotoAndPlay(2);
            explotionbonus3.x = enemy1.x;
            explotionbonus3.y = enemy1.y;
            enemy1.y = 1000;
            score -=5;
            scoretxt.text = String (score);
   }
}
}

Aucun commentaire:

Enregistrer un commentaire