【发布时间】:2014-07-05 21:40:51
【问题描述】:
我想要上图中的边界。想象一下黑色是物理启用的墙,红点是英雄。英雄必须在边界内移动。
self.physicsBody = [SKPhysicsBody bodyWithEdgeLoopFromRect:self.frame];
只创建直线。
在 iOS7 或 iOS8 中可以吗?
【问题讨论】:
标签: ios sprite-kit game-physics
我想要上图中的边界。想象一下黑色是物理启用的墙,红点是英雄。英雄必须在边界内移动。
self.physicsBody = [SKPhysicsBody bodyWithEdgeLoopFromRect:self.frame];
只创建直线。
在 iOS7 或 iOS8 中可以吗?
【问题讨论】:
标签: ios sprite-kit game-physics
我想你想要bodyWithEdgeLoopFromPath:,你传递一个CGPathRef。您来自UIBezierPath 的can get that。像这样的:
UIBezierPath *path = [...]; //Create path to your specifications
self.physicsBody = [SKPhysicsBody bodyWithEdgeLoopFromPath:path.CGPath];
唯一的要求是路径不能与自身相交。
【讨论】: