ForumsProgramming ForumhitTest?

4 3137
NightfangII
offline
NightfangII
47 posts
Nomad

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

  • 4 Replies
mullet139
offline
mullet139
2 posts
Nomad

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

NightfangII
offline
NightfangII
47 posts
Nomad

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.

dank
offline
dank
986 posts
Peasant

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
}
}
NightfangII
offline
NightfangII
47 posts
Nomad

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.

Showing 1-4 of 4