0 Members and 1 Guest are viewing this topic.
class Ship extends MovieClip{ var velocity = 10; var shoottimer = 0; var enemytimer = 0; var enemies = []; function Explode(){ var explosion = _root.attachMovie("Explosion","Explosion"+_root.getNextHighestDepth(),_root.getNextHighestDepth()); explosion._x = _x; explosion._y = _y; this.removeMovieClip(); } function onEnterFrame(){ shoottimer += 1; enemytimer += 1; if (Key.isDown(Key.RIGHT)){ _x += velocity; } if (Key.isDown(Key.LEFT)){ _x -= velocity; } if (Key.isDown(Key.UP)){ _y -= velocity; } if (Key.isDown(Key.DOWN)){ _y += velocity; } if (Key.isDown(Key.SPACE) && (shoottimer > 8)){ shoottimer = 0; var missile = _root.attachMovie("Missile","Missile"+_root.getNextHighestDepth(),_root.getNextHighestDepth()); missile._x = _x + 101; missile._y = _y + 37; } if (enemytimer >= 65){ enemytimer = 0; var enemy = _root.attachMovie("EnemyShip","EnemyShip"+_root.getNextHighestDepth(),_root.getNextHighestDepth()); enemies.push(enemy); } }}
class EnemyShip extends MovieClip{ var speed; function Explode(){ var explosion = _root.attachMovie("Explosion","Explosion"+_root.getNextHighestDepth(),_root.getNextHighestDepth()); explosion._x = _x; explosion._y = _y; this.removeMovieClip(); } function onLoad(){ _x = 1050; _y = Math.random() * 200 + 50; speed = Math.random() * 5 + 2; } function onEnterFrame(){ _x -= speed; if (this.hitTest(_root.mainship)) { Explode(); } }}
class Missile extends MovieClip{ var speed = 8; function onEnterFrame() { _x += speed; if (_x > 1000) { this.removeMovieClip(); } for(var i in _root.Ship.enemies){ if(this.hitTest(_root.Ship.enemies[i])){ this.removeMovieClip(); _root.Ship.enemies[i].Explode(); } } }}
class Explosion extends MovieClip{ function onEnterFrame(){ if(this._currentframe == this._totalframes){ this.removeMovieClip();} }}
class Background extends MovieClip { function onEnterFrame(){ _x -= 1; if (_x < -1399){ _x = 0; } }}
for(var i=0; i<_root.Ship.enemies.length; i++) {...}
var myArray:Array = Array();
var myArray= [];
var myArray = [];var myArray = new Array();
array = []