当前位置: 动力学知识库 > 问答 > 编程问答 >

ios - Issue with SKPhysicsBody from http://mortenjust.com/path-generator/

问题描述:

I am using this to create my SKPhysicsBodys: http://mortenjust.com/path-generator/ and I'm having an issue. My game is universal, so it doesn't work right when I attempt to use this program, it doesn't place the physics body where I want it to. Also, I used the @3x image and the physics body is bigger than the image on devices like the iPhone 5s. Does anyone know the fix for this?

Here's the code:

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)

分享给朋友:
您可能感兴趣的文章:
随机阅读: