PDA

View Full Version : Random object generation



WobblyFork
November 24th, 2002, 06:02 PM
I guess this is a little vague, but always worth a shot :)

Anyone have a good idea for what kind of script framework I should use to:

1. Make a movieClip appear in a random place (I've got this down fine, but...)

2. Make other instances of the movie clip appear in other random places while the first one is still on-screen, but at random intervals?

Keep in mind the basis for this question is that I'm making a game where targets must appear and disappear if not shot, but I want other targets to be able to appear on-screen at the same time if the user hasn't gotten around to destroying the first, second, etc. yet.

Well, thanks for any suggestions! :)
- wobbly

Jubba
November 24th, 2002, 06:25 PM
establish a frequency.

nFreq= Math.round(Math.random()*10)

then use an if statement to check when the value is a number, I used 5.



_root.onEnterFrame = function(){
nFreq = Math.round(Math.random()*10)
if(nFreq == 5){
//
//Here you would duplicate the movieclip
//Or attach the MovieClip
//
}
}

h88
November 24th, 2002, 06:29 PM
Here:

h88
November 24th, 2002, 06:33 PM
Replied together, hmm, 4 min difference!

WobblyFork
November 25th, 2002, 06:16 PM
Hey, this is great... you're all so responsive and helpful :)

Jubba, thanks, I learned a new trick :)

h88 ... I must say, after being on the board a little while, you're awesome :beam:

Thanks again :)

- wobbly

h88
November 25th, 2002, 06:17 PM
No problem. :)