0

我在绘制一个看起来像半管的多边形的 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];

当我尝试让身体与他人互动时,它的行为就像创建了一些更小、变形的多边形。

非常感谢任何见解或帮助!

4

1 回答 1

0

尝试使用 Thomas Zinnbauer 创建的物理调试器。

https://github.com/ymc-thzi/physicsDebugger

它是调试物理实体的好工具,因为它可以在精灵上绘制它们的形状。

于 2013-11-26T12:34:33.353 回答