【问题标题】:How to Create Curved Level Boundaries with Sprite Kit如何使用 Sprite Kit 创建弯曲的关卡边界
【发布时间】:2014-07-05 21:40:51
【问题描述】:

我想要上图中的边界。想象一下黑色是物理启用的墙,红点是英雄。英雄必须在边界内移动。

self.physicsBody = [SKPhysicsBody bodyWithEdgeLoopFromRect:self.frame];

只创建直线。

在 iOS7 或 iOS8 中可以吗?

【问题讨论】:

    标签: ios sprite-kit game-physics


    【解决方案1】:

    我想你想要bodyWithEdgeLoopFromPath:,你传递一个CGPathRef。您来自UIBezierPathcan get that。像这样的:

    UIBezierPath *path = [...]; //Create path to your specifications
    self.physicsBody = [SKPhysicsBody bodyWithEdgeLoopFromPath:path.CGPath];
    

    唯一的要求是路径不能与自身相交。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多