我正在使用它创建我的SKPhysicsBody
:http://mortenjust.com/path-generator/而且我遇到了问题。我的游戏是通用的,所以当我尝试使用这个程序时它不能正常工作,它不会将物理体放在我想要的地方。此外,我使用了@ 3x图像,物理体比iPhone 5s等设备上的图像大。有谁知道这方面的修复?
以下是代码:
let offsetX = airplane1.size.width * airplane1.anchorPoint.x
let offsetY = airplane1.size.height * airplane1.anchorPoint.y
let path = CGPathCreateMutable()
CGPathMoveToPoint(path, nil, 3 - offsetX, 75 - offsetY)
CGPathAddLineToPoint(path, nil, 6 - offsetX, 80 - offsetY)
CGPathAddLineToPoint(path, nil, 12 - offsetX, 84 - offsetY)
CGPathAddLineToPoint(path, nil, 19 - offsetX, 85 - offsetY)
CGPathAddLineToPoint(path, nil, 78 - offsetX, 85 - offsetY)
CGPathAddLineToPoint(path, nil, 142 - offsetX, 146 - offsetY)
CGPathAddLineToPoint(path, nil, 159 - offsetX, 146 - offsetY)
CGPathAddLineToPoint(path, nil, 159 - offsetX, 143 - offsetY)
CGPathAddLineToPoint(path, nil, 121 - offsetX, 86 - offsetY)
CGPathAddLineToPoint(path, nil, 170 - offsetX, 86 - offsetY)
CGPathAddLineToPoint(path, nil, 189 - offsetX, 105 - offsetY)
CGPathAddLineToPoint(path, nil, 196 - offsetX, 100 - offsetY)
CGPathAddLineToPoint(path, nil, 189 - offsetX, 81 - offsetY)
CGPathAddLineToPoint(path, nil, 192 - offsetX, 78 - offsetY)
CGPathAddLineToPoint(path, nil, 192 - offsetX, 75 - offsetY)
CGPathAddLineToPoint(path, nil, 192 - offsetX, 71 - offsetY)
CGPathAddLineToPoint(path, nil, 189 - offsetX, 68 - offsetY)
CGPathAddLineToPoint(path, nil, 196 - offsetX, 49 - offsetY)
CGPathAddLineToPoint(path, nil, 189 - offsetX, 43 - offsetY)
CGPathAddLineToPoint(path, nil, 170 - offsetX, 63 - offsetY)
CGPathAddLineToPoint(path, nil, 121 - offsetX, 62 - offsetY)
CGPathAddLineToPoint(path, nil, 160 - offsetX, 5 - offsetY)
CGPathAddLineToPoint(path, nil, 158 - offsetX, 2 - offsetY)
CGPathAddLineToPoint(path, nil, 150 - offsetX, 2 - offsetY)
CGPathAddLineToPoint(path, nil, 141 - offsetX, 2 - offsetY)
CGPathAddLineToPoint(path, nil, 78 - offsetX, 64 - offsetY)
CGPathAddLineToPoint(path, nil, 17 - offsetX, 64 - offsetY)
CGPathAddLineToPoint(path, nil, 6 - offsetX, 67 - offsetY)
CGPathCloseSubpath(path)
airplane1.physicsBody = SKPhysicsBody(polygonFromPath: path)