Community

hitTest?

Posted Aug 6, '08 at 2:46pm

NightfangII

NightfangII

42 posts

Gold - Serf

Does hitTest(x, y, shape) count the MovieClips that are referenced in the Movie calling hitTest? i.e. If you have an array of movies that were added by attaching them to _root, and the array is in a movieclip called mc, then if you called mc.hitTest(200, 200, true) would it return true if 200,200 was in one of the movies in the array?

Sorry if I'm not clear enough.

Thanks

Posted Aug 8, '08 at 1:27pm

mullet139

mullet139

2 posts

 -

if I understand what you're describing:
mc has a bunch of clips in it.
then you go mc.hitTest(200, 200, true);

Then yes if any of the clips in mc are hitting it will return true. I would avoid calling it an array as it makes it kind of confusing

 

Posted Aug 8, '08 at 1:34pm

NightfangII

NightfangII

42 posts

Gold - Serf

Not quite. In the main timeline I created an Array in mc (mc.myArray = new Array(30)) and filled that array with movie clips that were gained by attaching them to the root (_root.mc.myArray[i] = _root.attachMovie("mc2", "mc" + i, _root.nextHighestDepth()).

I'm using AS2.

 

Posted Aug 8, '08 at 7:15pm

dank

dank

691 posts

Wood - Lord

Moderator

What you will need to do is cycle through all the elements and test for a collision.

for(i = 0; i < mc.myArray.length - 1){
     if(this.hitTest(mc.myArray[i].x, mc.myArray[i].y, true)){
           // Hit
     }
}

 

Posted Aug 9, '08 at 5:12pm

NightfangII

NightfangII

42 posts

Gold - Serf

Umm... Here's what I'm trying to do:
I'm trying to check the collision between mc and another movie, but not between mc.myArray and the other movie.

 
Reply to hitTest?

You must be logged in to post a reply!