I’m trying to make duplicated movie clips scroll down the screen (asteroids) for an experimental game but I just can’t get it working. :-\
I’m using this to duplicate the movieclip:
i=i+1;
duplicateMovieClip (“m0”, “m”, i);
and trying to get the movieclips to scroll down with this:
p=eval(“m” add i);
p._y+=2;
Can anyone tell me somekind of an example to make renamed duplications scroll down the screen?
Thanks Jubba. I think I found an easier way to do it thanks to electrongeek.
I just made the code inside the movieclip in its own frames.
Now I just have to duplicate it… Let’s see how easy that’ll be…
(probably gonna fight with it the rest of the night
Ok, I’m just gonna try to make my life a little easier and my sleep a little longer and ask from you guys.
How should I duplicate the movieclip? I need it to be duplicated in certain periods of time with a timer like:
time++;
if ( time>100 ) {
duplicateMovieClip (_root.m0, “m”, 0 ); // possible?
}
and I need them to duplicate in a random fashion along the x axel which is 640 pixels long…
Maybe you get the idea even with the lack of my explanation skills.
Thanks for helping me out, I really appreciate it.
THANKS!! You got the duplication working! You’re a genius!
I wanted them at random times for Flash MX.
Still, they won’t move down… Working on it… Tip me if you want.
Oh, I got another thing going on here…
So there are still 2 things I really need help with… Sorry for being such a bother… :-\
The duplications wouldn’t move down. Don’t know why but they seemed to twitch at the top when I tried debugging but they only moved when they were duplicated?? Anyways another thing came up… The collision detection. I need to get a ship to collide with the asteroids. So I need to know how to assign many targets for the collision detection like this:
if (_root.ship, hitTest (_root[“m”+ii])) // that didn’t work though
I really have to go sleep so I’ll be checking the thread first thing in the morning. Thank you all for your help.
Thanks, it works better now but they still stop when the next one duplicates. :-\
Even though I think the bigger problem here is going to be the collision detection. working on it:beam:
I don’t get it. :-\ I think it’s because it only moves the one that the value ii currently is.
hit test is easy. You can use the highly underused “for…in” loop . The for in loop will detect everything within a target, and perform the same action on each, even if you don’t know what their names are.
for (mc in _root) {
_root.ship.hitTest(mc);
}
or something like that. (I don’t have Flash on my machine here either. )
Mind you, I’m not 100% on this either… but the best way of implimenting this might be like so
_root.ship.onEnterFrame = function(){
for (mc in _root) {
this.hitTest(mc);
}
}
maybe one of my more experienced MX brothers can help out fixing that code up, but the ‘for…in’ loop is definitely the way you want to go for hit detection.
well keep in mind that I’m still guessing here so the further we explore this without help from Jubba or one of the others, the more we may have to backtrack, and or the more you may be needlessly slamming your head against a wall.
I think it should be this way.
_root.ship.onEnterFrame = function(){
for (mc in _root) {
if (this.hitTest(mc)) {
this._alpha-=10;
}
}
}
but this (if it works correctly) will only fade the ship to _alpha 90. If you want it to completely disapear we’ll have to work that out differently.
Keep in mind also that this assumes your asteroids are located in the _root timeline.
*Originally posted by ilyaslamasse *
And the reason why it disappears is probably because ship itself is in _root (as your path seems to show). And ship is definitely colliding with ship