View Full Version : [AS2] random enemies
Adam_C
06-29-2009, 08:59 PM
I have nine enemies - "enemy1_mc" , "enemy2_mc" ... "enemy9_mc"
i want my game so that when you click on an enemy (that has randomly popped up) a new random enemy pops up and repeats this process over and over . . .
are there any ideas? examples?
much appreciated ! :)
thanks
bluemagica
06-29-2009, 09:19 PM
You have nine enemies? no friends? lol
Anyway:
put all enemies in a single mc in separate frames, and do something like
this.onClick = function()
{
this._x = Math.random()*400;
this._y = Math.random()*400;
this.gotoAndStop(Math.ceil(Math.random()*9))
}
Adam_C
06-30-2009, 07:34 PM
:P and thanks v much for your help ! :)
by the way, what is Math.ceil ? i haven't seen that before?
thanks. Adam_C.
bluemagica
06-30-2009, 07:44 PM
Its similar to Math.round, but it always rounds to the larger number... so 4.1 becomes 5
Adam_C
06-30-2009, 07:45 PM
Its similar to Math.round, but it always rounds to the larger number... so 4.1 becomes 5
thanks. makes sense :)
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.