2
votes

I've been trying to find the most efficient way to get per pixel collision in SpriteKit for iOS 7 (SpriteKit for iOS 8 has support for this, however). Of course I would like to use a box or circle to represent the sprites' physics bodies, but unfortunately the nature of the game demands per pixel collision.

I know I could manually draw the CGPaths around the sprites, but I'm trying to save myself some time / create a method for long term use / learn something new. Since the images for the sprites are drawn on an alpha background (png file), I was wondering if using edge detection or some other method would work to trace the non-alpha edges with a CGPath. This would happen during game initialization, and the CGPaths would be turned into physics bodies and be saved. I couldn't find much help online, though I did read that this could potentially be very tricky.

Any help is much appreciated. Thanks!

1

1 Answers

0
votes

As far as I'm aware you can't trace the non alpha edges automatically, I use a tool where you drag and drop a sprite into a box and click points to represent the physics body. The tool then returns the code for the path you just defined, it makes things a little easier until iOS 8 is out.