Skip to main content
Participating Frequently
July 29, 2006
Question

how to detect the Collission for duplicated movieclps

  • July 29, 2006
  • 2 replies
  • 308 views
Hey guys .. i am back with set of query..till now .. key press movement a rocket (mc) is moving left right up down in a defined stage area. and i am able to generate some fire balls randomize falling from top. this is just i am duplicating the movie clip(fireball_mc) .... now i want incase or when the rocket (mc) touch the fire ball programm shold detect the collsion and generate a score board. well for this i have tried a script for two movie clips ... wchich is working but ..i don know or i m not gettng the logic how to detect the collission for duplicated movie clips... well i m just giving the script for oinly 2 movie clips coliding...can any one tell me how to do it with randmize or duplkicated mcs??

for 2 movie clip ...

_root.mc1.onEnterFrame = function() {
if(this.hitTest(_root.egg)) {
_root.result="Oh no..... we are dead";
} else {

_root.result="we are going fine";
}

}

(this is happening ..but let me know how can i get the same result for ranndom mcs)

hope someone can help me out ...

i appriciate ur valuable time to read this..

thanking you

This topic has been closed for replies.

2 replies

kglad
Community Expert
Community Expert
August 1, 2006
you're welcome.
kglad
Community Expert
Community Expert
July 29, 2006
you need to loop through all the movieclips for which you want to execute a hit test. you could store them in any array (use the push method) and loop through the elements of that array.
__aryan__Author
Participating Frequently
July 29, 2006
Hey thx for ur suggestion...but as i said m very much new to actionscript (more designer) so i don have much idea... most of the things i m doing for this game i m going through lots of references then i tried to understand te codes m implmenting them to my need..can u explain me little more about arrays u haves asked for loops u asked me to use the hittest function..please /.. i will be greatfull to u... thx
kglad
Community Expert
Community Expert
July 29, 2006
somewhere in your code you are duplicating a movieclip. first create an array in which to store your duplicated movieclips (say dupMCA) and then if you use whateverMC.duplicateMovieClip("...",depthVar) change to: