actionscript 3 - How do you detect multiple objects going offscreen? -


i making game in as3, , want have "health bar". when 1 of "alien" objects hits earth, health go down. not know how make stage register object gone offscreen, or "hit ground". great!

var aliens = [new alien(), new alien(), new alien()]; var health = 10;  // check position of aliens on each frame this.addeventlistener(event.enter_frame, enterframehandler);  function enterframehandler(event:event):void {     (var i:int = 0; < aliens.length; ++)     {         // if alien's y position equal or greater         // stage height, he's hit deck         if (aliens[i].y <= this.stage.stageheight)          {             health --;         }     } } 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -