The problem with that code is that the chances of random(100) hitting exactly 30 is a billion to one. You would have to put like Math.floor(random(100)) or Math.round(random(100)); to get a round number, but then your chances of seeing a movieClip duplicate would be a hundred to one. That could be a long time.
If you just want them to randomly show up, you can use this:
[AS]
//this code is in a seperate movieClip - I usually make an
//empty one on the side of the stage for my duplicate codes
onClipEvent(enterFrame){
if(getTimer()>randomTime){
randomTime=getTimer()+(1000+Math.random()*10000);
//that will put your time randomly between 1 sec and 10 sec
i++;
//i++ is the same as i=i+1;
duplicateMovieClip(_root.stick, “stick”+i, i);
}
[/AS]
Then put your movement code on the original ‘stick’ movieClip:
[AS]
onClipEvent(load){
//where you want ‘stick’ to appear
_x=200;
_y=200;
}
onClipEvent(enterFrame){
_x-=5;
//you may want to delete MCs when they leave the stage too
if(_x<0){
this.removeMovieClip();
}
}
[/AS]
There ya go!!
I tried learning how hitTest works with a game that I made. The one that I made has some bugs, but the entire post has other peoples suggestions that I never got around to try. I haven’t really gotten into games (yet). At the end of this thread, there’s a game like mine - except it works. So, here it is:
I played with it, but I can’t figure it out. You may consider starting a new thread with ‘hitTest’ in the title - that way people who know hitTest will look at it. Sorry I couldn’t help more. The code you want is in that zip file that is on page three of the thread I spoke of before - I couldn’t figure it out, it’s beyond me. :*(