0

我正在尝试将两个节点与一个固定的 SKPhysicsJoint 绑定在一起我想出了这个代码:

var anchor = CGPointMake(hero.position.x + 10,hero.position.y)
var fixedJoint = [SKPhysicsJointFixed .jointWithBodyA(hero.physicsBody!, bodyB: shield.physicsBody!, anchor: anchor)]

问题来了:

self.physicsWorld.addJoint(fixedJoint)

它给了我这个错误:

Cannot convert value of type '[SKPhysicsJointFixed]' to expected argument type 'SKPhysicsJoint'

任何帮助表示赞赏。

4

1 回答 1

1

您将 fixedJoint 放入一个数组中,试试这个,省略 [ 和 ]。

let anchor = CGPointMake(hero.position.x + 10,hero.position.y)
let fixedJoint = SKPhysicsJointFixed.jointWithBodyA(hero.physicsBody!, bodyB: shield.physicsBody!, anchor: anchor)

注意:如果你不改变你的属性,让它们代替 var。

于 2016-06-16T17:19:54.657 回答