Hi! So, I have this code for a game I am creating in my digital imaging class. This is the code I am using on my scene which will have the first level of gameplay. Here’s the problem, when I go to the next scene, the enemies that are falling from the top of the screen continue on, past the next level and onto the winning, losing, and main screen. I was told it had something to do with the _root. , but I have no idea! Any help will be greatly appreciated! Thanks.
i = 0;
enemies = [5];
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._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++;
}
enemy_interval = setInterval(spawnEnemy, 2000);