cocos2d V3 PhysicsCollision身体落入另一个

时间:2014-03-23 09:42:30

标签: cocos2d-iphone game-physics

我制作两个CCNode,使用cocos2d v3。
节点A是静态物理,节点B是动态的。
B的anchorPoint是ccp(0,0)
当B跌落并与A碰撞时,我发现了b的位置。它低于A的位置 它似乎在很短的时间内陷入中间 它怎么能不属于一个,也能在正常碰撞中遇到物理效应?

1 个答案:

答案 0 :(得分:0)

简短的回答是你不能这样做。碰撞检测在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的图表,以便大致了解更新循环和物理模拟在这些系统中是如何发生的。

https://developer.apple.com/library/ios/documentation/GraphicsAnimation/Conceptual/SpriteKit_PG/Introduction/Introduction.html

相关问题