View Full Version : random factor
Slayton
07-13-2004, 09:19 PM
basicly im making a whack a mole game..anyway I can make it so the moles randomly pop up instead of in a fixed path?
senocular
07-13-2004, 09:30 PM
depends on how you have it set up.
... how do you have it set up?
Dr Warm
07-14-2004, 01:11 PM
Yeah i was trying to figure out how to do this myself awhile ago, try mucking around with the switch function:
onClipEvent(enterFrame){
n = random(5)+1;
switch(n) {
case 1:
_root.gotoAndPlay("mole1");//make a mole pop up
break;
case 2:
_root.gotoAndPlay("mole2");
break;
case 3:
_root.gotoAndPlay("mole3");
break;
case 4:
_root.gotoAndPlay("mole4");
break;
case 5:
_root.gotoAndPlay("mole5");
break;
}
}
obviously you can change it to make more/less moles come up.
senocular
07-14-2004, 01:57 PM
the above can be simplfied to
onClipEvent(enterFrame){
_root.gotoAndPlay("mole"+(random(5)+1));
}
Dr Warm
07-15-2004, 02:53 AM
Yeah, thats alot better, my ways a bit outdated i think
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.