开发者

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!


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜