【发布时间】:2014-03-23 09:42:29
【问题描述】:
我做了两个CCNode,使用cocos2d v3。
节点 A 是静态物理,节点 B 是动态的。
而B的锚点是ccp(0,0)
当 B 跌倒并与 A 碰撞时,我发现 b 的 position.y 低于 A 的 position.y
它似乎在很短的时间内就被夹在了中间。
怎么能不合二为一,又能满足正常碰撞的物理效果呢?
【问题讨论】:
标签: cocos2d-iphone game-physics
我做了两个CCNode,使用cocos2d v3。
节点 A 是静态物理,节点 B 是动态的。
而B的锚点是ccp(0,0)
当 B 跌倒并与 A 碰撞时,我发现 b 的 position.y 低于 A 的 position.y
它似乎在很短的时间内就被夹在了中间。
怎么能不合二为一,又能满足正常碰撞的物理效果呢?
【问题讨论】:
标签: cocos2d-iphone game-physics
简短的回答是你不能这样做。碰撞检测在 CS 中定义为对象的交集。 Wikipedia
碰撞检测是复杂物体的一个棘手问题,因此最好坚持使用Chipmunk 为您处理。
物理计算以“更新循环”的方式运行。
您可以使用以下属性调整 CCPhysicsNode。
/**
* The number of solver iterations the underlying physics engine should run.
* This allows you to tune the performance and quality of the physics.
* Low numbers will improve performance, but make the physics spongy or rubbery.
* High numbers will use more CPU time, but make the physics look more solid.
* The default value is 10.
*/
@property(nonatomic, assign) int iterations;
/**
* Physics bodies fall asleep when a group of them move slowly for longer than the threshold.
* Sleeping bodies use minimal CPU resources and wake automatically when a collision happens.
* Defaults to 0.5 seconds.
*/
@property(nonatomic, assign) CCTime sleepTimeThreshold;
我认为您应该查看SpriteKit 的图表,以大致了解更新循环和物理模拟在这类系统中是如何发生的。
【讨论】: