在我的应用程序中,我有一堆 CCSprite,我想要一个碰撞检测功能,该功能仅在 CCSprite 中的非透明像素发生碰撞时才起作用。我不想局限于碰撞精灵之间的颜色。我认为这就是 Cocos2D 论坛中的“像素完美碰撞检测”线程所做的,但我想使用任何颜色进行真正的碰撞。这种碰撞检测将在我的游戏循环中,所以它不会太昂贵。无论如何,有人对我如何做到这一点有任何想法吗?如果可以的话,我愿意使用 Cocos2D、Box2D 或 Chipmunk 甚至 UIKit。
谢谢!
在我的应用程序中,我有一堆 CCSprite,我想要一个碰撞检测功能,该功能仅在 CCSprite 中的非透明像素发生碰撞时才起作用。我不想局限于碰撞精灵之间的颜色。我认为这就是 Cocos2D 论坛中的“像素完美碰撞检测”线程所做的,但我想使用任何颜色进行真正的碰撞。这种碰撞检测将在我的游戏循环中,所以它不会太昂贵。无论如何,有人对我如何做到这一点有任何想法吗?如果可以的话,我愿意使用 Cocos2D、Box2D 或 Chipmunk 甚至 UIKit。
谢谢!
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