7 Replies - 3827 Views - Last Post: 13 May 2011 - 11:27 AM

#1 NiteFlame  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 34
  • Joined: 11-June 10

AS3 HitTestPoint

Posted 11 May 2011 - 07:52 PM

my_mc.hitTestPoint(mouseX,mouseY,true);

i get that when ever that the mouse comes into contact with anything inside my_mc that not part of the alpha channel if gives a return of "true" (at lest i think that's how it works)

but what i want is a MC to a MC test and i havnt yet found any thing on google that helps and i dnt know how to search the forums.

so what i think the format is

my_mc1.hitTestPoint(my_mc2.x,mymc2.y,true);

but that didnt seem to work, so what am i doing wrong or even am i in the ballpark form what i tried.

Is This A Good Question/Topic? 0
  • +

Replies To: AS3 HitTestPoint

#2 lordofduct  Icon User is offline

  • I'm a cheeseburger
  • member icon


Reputation: 2668
  • View blog
  • Posts: 4,786
  • Joined: 24-September 10

Re: AS3 HitTestPoint

Posted 11 May 2011 - 11:22 PM

flash does not have a built in pixel perfect collision test between two Sprites (or MovieClips). You can only test if their bounding boxes are overlapping.

People have created their own methods of doing the test using various collision algorithms. They are more complex and can't really be accomplished in 1 or 2 lines of code.
Was This Post Helpful? 0
  • +
  • -

#3 NiteFlame  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 34
  • Joined: 11-June 10

Re: AS3 HitTestPoint

Posted 12 May 2011 - 03:47 AM

ok what if i turn both my images into bitmap data, have a test for oject1 that all non-alpha points and test once it hits object2 to also find non-alpha point is that do able or am i talking out my ass now
Was This Post Helpful? 0
  • +
  • -

#4 NiteFlame  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 34
  • Joined: 11-June 10

Re: AS3 HitTestPoint

Posted 12 May 2011 - 05:40 AM

ok forget what i asked by can i do a hitTest of a mc that is a child of a child of a child of a parent

-----Main------
HitTestImg............child
......................child
......................Other HitTestImg

This post has been edited by NiteFlame: 12 May 2011 - 05:41 AM

Was This Post Helpful? 0
  • +
  • -

#5 chinchang  Icon User is offline

  • Indie Game Developer
  • member icon

Reputation: 192
  • View blog
  • Posts: 727
  • Joined: 22-December 08

Re: AS3 HitTestPoint

Posted 12 May 2011 - 08:18 AM

Yes...you can. That is a technique widely used when you want a large body to have specific points for hitTest. In that you add small movieclips inside the large one and use them to check collision.
Was This Post Helpful? 0
  • +
  • -

#6 NiteFlame  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 34
  • Joined: 11-June 10

Re: AS3 HitTestPoint

Posted 12 May 2011 - 11:13 AM

well i was looking into somethings and it looks like if i use local to global for my bullets i can use the hitTest withing my plane class hopefully any ways
Was This Post Helpful? 0
  • +
  • -

#7 Prototypical  Icon User is offline

  • D.I.C Head

Reputation: 39
  • View blog
  • Posts: 137
  • Joined: 20-April 11

Re: AS3 HitTestPoint

Posted 12 May 2011 - 08:26 PM

If you are interested in Pixel Perfect Collision as it's called, you can check out this code :

Pixel Perfect Collision
Was This Post Helpful? 1
  • +
  • -

#8 NiteFlame  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 34
  • Joined: 11-June 10

Re: AS3 HitTestPoint

Posted 13 May 2011 - 11:27 AM

View PostPrototypical, on 12 May 2011 - 10:26 PM, said:

If you are interested in Pixel Perfect Collision as it's called, you can check out this code :

Pixel Perfect Collision


that was exactly what i needed thanks
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1