Chipmunk collision detection

删除回忆录丶 提交于 2019-12-07 06:24:35

问题


I am completely new to chipmunk and I have just been using it for a few days, so I'm guessing this is something pretty obvious, however I cannot find any documentation for this. Is there any callback or method in chipmunk that tells you that 2 given shapes have collided?.

If not is the best way to simply use cgrectcontains on the sprites?.

-Oscar


回答1:


You can get to it from Ipthnc's link, but this is the documentation you're probably looking for - it details the collision callback system:

http://chipmunk-physics.net/release/ChipmunkLatest-Docs/#CollisionCallbacks




回答2:


Does this help:

http://code.google.com/p/chipmunk-physics/wiki/CollisionDetection

// Reference line
// Does not collide with other objects, we just want to draw it.
shape = cpSegmentShapeNew(staticBody, cpv(-320,0), cpv(320,0), 0.0f);
shape->collision_type = 1;
cpSpaceAddStaticShape(space, shape);
// Add a collision pair function to filter collisions
cpSpaceAddCollisionPairFunc(space, 0, 1, NULL, NULL);

Finally, use Google Code Search:

http://www.google.com/codesearch?q=lang:c+chipmunk+collision&hl=en&btnG=Search+Code



来源:https://stackoverflow.com/questions/2025035/chipmunk-collision-detection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!