我正在为 SKSpriteNode 的物理体创建自定义边缘路径。
CGMutablePathRef edgePath = CGPathCreateMutable();
CGPathMoveToPoint(edgePath, NULL, -100, -70);
CGPathAddLineToPoint(edgePath, NULL, -100, 40);
CGPathAddLineToPoint(edgePath, NULL, -80, -20);
CGPathAddLineToPoint(edgePath, NULL, 30, -20);
CGPathAddLineToPoint(edgePath, NULL, 100, 100);
CGPathAddLineToPoint(edgePath, NULL, 100, -70);
CGPathCloseSubpath(edgePath);
我尝试使用以下代码分配physicsBody:
sprite.physicsBody = [SKPhysicsBody bodyWithEdgeLoopFromPath:edgePath];
sprite.physicsBody = [SKPhysicsBody bodyWithPolygonFromPath:edgePath];
sprite.physicsBody = [SKPhysicsBody bodyWithEdgeChainFromPath:edgePath];
这些都不能使精灵受到重力的影响。
但是,如果我使用简单bodyWithCircleOfRadius:
的精灵会受到重力的影响。
任何人都可以解释为什么会这样吗?