Is there a good way to get pixel-perfect collision detection in XNA?

Posted by ashes999 on Game Development See other posts from Game Development or by ashes999
Published on 2011-07-25T13:18:57Z Indexed on 2012/06/13 10:48 UTC
Read the original article Hit count: 313

Filed under:
|
|

Is there a well-known way (or perhaps reusable bit of code) for pixel-perfect collision detection in XNA?

I assume this would also use polygons (boxes/triangles/circles) for a first-pass, quick-test for collisions, and if that test indicated a collision, it would then search for a per-pixel collision.

This can be complicated, because we have to account for scale, rotation, and transparency.

WARNING: If you're using the sample code from the link from the answer below, be aware that the scaling of the matrix is commented out for good reason. You don't need to uncomment it out to get scaling to work.

© Game Development or respective owner

Related posts about XNA

Related posts about 2d