【问题标题】:cocos2d V3 PhysicsCollision body fall into anothercocos2d V3 物理碰撞体落入另一个
【发布时间】: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


    【解决方案1】:

    简短的回答是你不能这样做。碰撞检测在 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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多