开发者

Removing bodies from joints in Chipmunk Physics

In Box2D, when a body that is connected to a joint is removed from the space, the joint is automatically deleted and you can do 开发者_如何学编程stuff in callbacks and so on.

Does Chipmunk do this? If so, how can I detect when a joint connection is 'broken'? Do I have to keep track of this stuff manually?


I'm not sure what you mean by detecting when a joint is broken. I don't believe Chipmunk breaks joints as part of the simulation. If the joint is broken because a body has been destroyed be careful on cleanup. From the documentation page for Chipmunk:

Be careful not to free a body before any shapes or constraints attached to it have been removed from a space.

Use cpSpaceRemoveConstraint and it will remove it from both bodies. Then free the constraint memory using cpConstraintFree.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜