我在绘制一个看起来像半管的多边形形状的SKPhysicsBody时遇到了麻烦。我得到的代码如下:
_halfpipe_left = [SKSpriteNode spriteNodeWithImageNamed:@"halfpipe_left"];
_halfpipe_left.position = CGPointMake(5*26, 5*26);
_halfpipe_left.anchorPoint = CGPointMake(0, 0);
CGMutablePathRef halfpipe_leftpath = CGPathCreateMutable();
CGPathMoveToPoint(halfpipe_leftpath, NULL, 0, 0);
CGPathAddLineToPoint(halfpipe_leftpath, NULL, 78, 0);
CGPathAddLineToPoint(halfpipe_leftpath, NULL, 78, 78);
CGPathAddLineToPoint(halfpipe_leftpath, NULL, 52, 78);
CGPathAddLineToPoint(halfpipe_leftpath, NULL, 48, 59);
CGPathAddLineToPoint(halfpipe_leftpath, NULL, 42, 47);
CGPathAddLineToPoint(halfpipe_leftpath, NULL, 31, 36);
CGPathAddLineToPoint(halfpipe_leftpath, NULL, 19, 30);
CGPathAddLineToPoint(halfpipe_leftpath, NULL, 0, 26);
CGPathCloseSubpath(halfpipe_leftpath);
_halfpipe_left.physicsBody = [SKPhysicsBody bodyWithPolygonFromPath:halfpipe_leftpath];
当我尝试让身体与他人互动时,它的行为就好像已经创建了一些更小,变形的多边形。
非常感谢任何见解或帮助!
答案 0 :(得分:0)
尝试使用Thomas Zinnbauer创建的物理调试器。
https://github.com/ymc-thzi/physicsDebugger
它是调试物理实体的一个很好的工具,因为它在精灵上绘制它们的形状。