我正在尝试将两个节点与固定的skphysics关键我想出了这个代码:
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'
任何帮助都将不胜感激。
您将固定接相放入数组中,试试看,省略[and]。
let anchor = CGPointMake(hero.position.x + 10,hero.position.y)
let fixedJoint = SKPhysicsJointFixed.jointWithBodyA(hero.physicsBody!, bodyB: shield.physicsBody!, anchor: anchor)
注意:如果您不突变您的属性会使它们放任,而不是var。