Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- stop();
- lives = 3;
- score = 0;
- i = 0;
- enemies = [];
- spawnEnemy = function(){
- _root.attachMovie("enemy", "enemy"+i, _root.getNextHighestDepth());
- _root["enemy"+i]._x = random(Stage.width);
- _root["enemy"+i]._y = 0;
- enemies.push("enemy"+i);
- _root["enemy"+i].onEnterFrame = function(){
- this._y += 3;
- if(this.hitTest(_root.player)){
- for(e = 0; e < _root.enemies.length; e++){
- if(_root.enemies[e] == this._name){
- _root.enemies.splice(e, 1);
- }
- }
- this.removeMovieClip();
- _root.lives--;
- }
- if(this._y > Stage.height){
- for(e = 0; e < _root.enemies.length; e++){
- if(_root.enemies[e] == this._name){
- _root.enemies.splice(e, 1);
- }
- }
- this.removeMovieClip();
- }
- }
- i++;
- }
- onEnterFrame = function(){
- if(lives < 0){
- nextFrame();
- }
- }
- enemy_interval = setInterval(spawnEnemy, 2000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement