In the past I mentioned some tutorials providing 2D collision detection techniques showing how to perform circle-to-rectangle, circle-to-circle (using UIKit), and vertex based collisions (with Cocos2D and Box 2D).
The most accurate collision method – pixel to pixel collisions – wasn’t mentioned simply because it can be brutally slow.
It is possible however to perform extremely fast pixel to pixel collisions using a pixel mask.
Steffen Itterheim has created a class known as KKPixelMaskSprite that inherits from CCSprite that automatically provides a pixel mask along with several methods for detecting collisions.
You can find the class along with an extensive tutorial on Steffen’s site here.
This looks like a terrific class for any Cocos2D developers wanting pixel accurate collisions at a decent speed. The speed of course can’t compare to vertex based collisions with only a few vertices, but if you really want pixel perfect collisions this loks like the way to go.
Submit A Resource
Have you created a useful tutorial, library or tool for iOS development that you would like to get in front of our 300,000+ monthly page views from iOS developers?
You can submit the url here.
The resources we feel will appeal to our readers the most will be posted on the front page.