Hey, does anyone know how to make a duplicated movie clip more... planned?
http://img297.imageshack.us/my.php?image=chri stmasgame8ox7.swf
I updated the collision testing finally! And I added a new enemy. I still need to work out some bugs (The swap depth code is kinda quirky right now)
I just can't seem to get the duplicated movie clips down. Either there's too many of them, or not enough, or they all come at once, etc... I need something that'll make it more organized. This is the code I'm using now:
Inside an as frame on the main timeline:
onLoad = function () {
i = 0;
};
onEnterFrame = function () {
i++;
if (random(50) == 0) {
duplicateMovieClip(_root.badelf, "badelf"+i, i);
}
if (random(50) == 1) {
duplicateMovieClip(_root.self, "self"+i, i+500);
}
if (random(50) == 2) {
duplicateMovieClip(_root.edeer, "edeer"+i, +1000);
}
};
Inside the enemy, named "badelf":
onClipEvent (load) {
this._x = 570;
this._y = random(170)+118;
speed = random(1)*5;
}
onClipEvent (enterFrame) {
this._x -= (Math.random()+1)*4;
}
onClipEvent (enterFrame) {
if (this._x<0) {
this.removeMovieClip();
}
}
onClipEvent (enterFrame) {
if (!this.hitTest(_root.jim)) {
this._x -= speed;
}
}
onClipEvent (enterFrame) {
thisDepth=this.getDepth(), otherDepth=_root.jim.getDepth();
if (_y>_root.jim._y && otherDepth>thisDepth) {
this.swapDepths(_root.jim);
}
if (_root.jim._y>_y && thisDepth>otherDepth) {
this.swapDepths(_root.jim);
}
}
onClipEvent (enterFrame) {
if (this.hitTest(_root.jim.firer.snowballr) || this.hitTest(_root.jim.firel.snowball)) {
this.gotoAndStop(2);
}
}
I need better code to orchestrate my enemy spawning. Any ideas?