我在绘制一个看起来像半管的多边形的 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];
当我尝试让身体与他人互动时,它的行为就像创建了一些更小、变形的多边形。
非常感谢任何见解或帮助!