Duplicating Probelm

See I want my MC to get duplicated only at a certain time or at certain points so I added this.

    if (random(100) == 30) {
        i = i+1;
        duplicateMovieClip(_root.stick, "stick"+i, i);
        this._x -= 5;
    }

And that does not seem to wrok.

it doesent add them.

::Bump::

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!!

[AS]Math.round(random(100));[/AS]
You’re a bit confused, Freddy.

The random function returns an integer, you don’t need to round the number. :stuck_out_tongue:

It does? I thought it was the same as Math.random() ??!! My bad!! Still, the chances are one in 100 - could be a long time. (Right?)
:confused:

No whow would I do a Hitest for that

hitTest another movieClip? Or the mouse? Is this for a game?

Yes it is

ne one I need the Duplicated HitTest for MCS hittin another

:;Bump::

Someone please help I have been looking all day just to figure out how to make a HitTest work on a Duplicated MC

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:

http://www.kirupaforum.com/forums/showthread.php?s=&threadid=25422&perpage=15&highlight=game%20hitTest&pagenumber=1

Good luck!(-:

As much as you helped me and that fourm hlped alot.

But it still dont work.Ill give the fla I am tired of this I tried like 50 times and search 100 times.

Hope maybe the someone can help.

Just if you do please comment the code or if you cant comment it at least tell me on the froums.

Hope ya help.

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. :*(

i was just playing around quickly and i got one stick to work and im trying more at the moment

ok now they all work

actually, after a while, it stops working :frowning:
i think…

i can fix that easy i just dint really want to it was only a exsample

is that what u wanted bulldog?

Not exactly.

Because
1.It slows down
2.It only work for 10 of them