I’m working on a game where you have to avoid walls and such.
Anyways, I made it so every ten seconds, the wall speed gets faster. This method works, but it has some bugs.
First, the duped MCs will not hitTest with the player. I know this is most likely caused because the duped MCs are on a negative depth. But I cannot fix it.
Also, whenever the generate() function runs, all the other walls disappear.
The code is below, if anyone can tell me what the problem is, I’d be real happy.
var speeed:Number = 10;
gen = setInterval(generate, 1000);
levelUpper = setInterval(levelUp, 10000);
function levelUp() {
if (speeed<25) {
speeed += 1;
level++;
}else{
speeed += 0;
level += 0;
}
}
i = 1;
function generate() {
i++;
var blueWall:MovieClip = attachMovie("wall", "wall"+i, this.getNextHighestDepth());
blueWall._x = Stage.width;
blueWall._y = random(Stage.height);
blueWall.onEnterFrame = function () {
with(this){
if (_x<0) {
removeMovieClip();
}
blueWall._x -= speeed;
}
}
};
//hitTesting
if (ship.hitTest(blueWall)) {
gotoAndStop(2);
}