0
我正在为SKSpriteNode的physicsBody创建自定义边缘路径。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:
,精灵将受到重力的影响。
任何人都可以抛出一些为什么发生这种情况?
bodyWithPolygonFromPath应该工作。其他人不会。粘贴代码如何将physicsBody附加到节点上,请 –