I'm currently having trouble with the depth of objects that I duplicate.
In this case I have a plane(s) that fly over and drop a bomb when I press SPACE. The more I press space, the more planes I get.
I didn't have any trouble with the depths of the planes, as I could easily get many on the screen. But when they are called to drop the bomb, the bombs appear, and when the next plane drops a bomb... the previous bomb is overwritten, or erased, and can be seen falling at the origin of the page(top left).
This is the script for the planes:
var i = 0;
var timer = 5;
this.onEnterFrame = function() {
timer++;
if (Key.isDown(Key.RIGHT)) {
object._x += 5;
}
if (Key.isDown(Key.LEFT)) {
object._x -= 5;
}
if (Key.isDown(Key.SPACE)) {
if (timer>=5) {
i++;
_root.attachMovie("full_plane","full_plane"+i,_root.getNextHighestDepth());
_root["full_plane"+i]._x = -15;
_root["full_plane"+i]._y = Math.random()*250;
timer = 0;
}
}
};
This is script for the bombs:
var k = 0;
dropped = false;
this.onEnterFrame = function() {
this._x += 10;
if (this._x>=_root.object._x) {
if (!dropped) {
k++;
_root.attachMovie("bomb","bomb"+k,_root.getNextHighestDepth());
_root["bomb"+k]._x = this._x;
_root["bomb"+k]._y = this._y+3;
dropped = true;
}
}
};
Can anyone explain how to fix this to me please?
Thanks.