A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Hittest for duplicated movieclips

  1. #1
    Junior Member
    Join Date
    Oct 2008
    Posts
    19

    Hittest for duplicated movieclips

    Could someone please tell me how to have a hittest for duplicated movieclips. I got it to detect a hit from the original movieclip, but not the ones that spawn off of it. My function renames the original movieclip+1. For example: flying_mc, flying_mc1, flying_mc2 ect...

    Thanks

  2. #2
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Can you post the code that you current are using?

  3. #3
    Junior Member
    Join Date
    Oct 2008
    Posts
    19
    yea, sorry

    Code:
    //initialize counter
    mycount = 0;
    //function to create multiple movieclips from single movie clip
    function createFlyingMC() {
    	if (mycount<800) {
    		flying_mc.duplicateMovieClip("flying_mc"+mycount, getNextHighestDepth());
    		randomX = 5000*Math.random();
    		randomY = 25*Math.random()+150;
    		eval("flying_mc"+mycount)._x = randomX;
    		eval("flying_mc"+mycount)._y = randomY;
    		
    
    
    		
    		mycount++;
    	} else {
    		clearInterval(ID);
    		for(var i = 0;i<10;i++){
    			removeMovieClip(eval("flying_mc"+i));
    			}
    	}
    }
    //function to periodically call another function
    ID = setInterval(createFlyingMC, 300);

    and my hittest looks like this:
    Code:
    onClipEvent (enterFrame) {
    
    	if (hitTest(_root.flying_mc.bigBomb_mc)) {
              trace("Collision Detected");
    	} else {
              trace("No Collision");
    	}
    }
    Which is in my jet movieclip. The jet is supposed to dodge the bombs.

  4. #4
    Junior Member
    Join Date
    Oct 2008
    Posts
    19
    I've been working on this attached file for the past 20 hours straight. no joke. I haven't had any sleep and I have been stuck on this hittest for the past 16 hours. I am very frustrated.

    Sorry I'm a bit grumpy
    Attached Files Attached Files
    Last edited by abel408; 12-03-2008 at 06:46 PM.

  5. #5
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Sorry, I can't open your file, I've only got Flash MX 2004.
    But, I made a dummy file, applied your code to it and modified it.
    Maybe you can adapt the code in the attached file...
    Last edited by dawsonk; 01-05-2009 at 11:18 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center