SimplyKiwi
SimplyKiwi

Reputation: 12444

Pixel collision detection?

In my app, I have a bunch of CCSprites and I want to have a collision detection feature that will work only when the non-transparent pixels in the CCSprites collide. I don't want to be restricted to color between the colliding sprites. I think thats what the 'Pixel Perfect Collision Detection' thread does in the Cocos2D forum, but I want to use any color for the real collision. This collision detection would be in my game loop so it can't be too expensive. Anyway, does anyone have any ideas on how I can do this? I am willing to use Cocos2D, Box2D or Chipmunk or even UIKit if it can do it.

Thanks!

Upvotes: 1

Views: 684

Answers (2)

gfdgfd
gfdgfd

Reputation: 104

It`s imposible to do if you dont want lose performance. Try to do a system colission based in circles, this in best way to do a collision

Upvotes: 1

slembcke
slembcke

Reputation: 1409

When talking about hardware rendered graphics, "I want pixel perfect collisions" and "I don't want them to be too expensive" are pretty mutually exclusive.

Either write a simpler renderer that doesn't allows such complex transformations, anti-aliasing or sub-pixel placement or use the actual GPU to render some sort of collision mask. The problem with doing that on the GPU is that it's fast to send stuff to the GPU and expensive to get it back. There's a reason why this technique is quite uncommon.

Chipmunk Pro's auto-geometry stuff supports turning images of various varieties into collision shapes, but isn't complete yet.

Upvotes: 3

Related Questions