Sprite kit Swift和SpriteKit:我无法创建SKPhysicsJoint
使用and,我想创建一个SKPhysicsJoint(例如),但问题是Xcode没有给我任何建议:Sprite kit Swift和SpriteKit:我无法创建SKPhysicsJoint,sprite-kit,swift,Sprite Kit,Swift,使用and,我想创建一个SKPhysicsJoint(例如),但问题是Xcode没有给我任何建议: 如果我尝试手动设置应该解决的问题(bodyA、bodyB、anchor),我可以这样做: myJoint.bodyA = ... myJoint.bodyB = ... 但是我不能这样设置锚点。。。看起来应该用初始化方法设置,但我不知道如何设置 let joint = SKPhysicsJointFixed.jointWithBodyA(node1.physicsBody, bodyB:nod
如果我尝试手动设置应该解决的问题(bodyA、bodyB、anchor),我可以这样做:
myJoint.bodyA = ...
myJoint.bodyB = ...
但是我不能这样设置锚点。。。看起来应该用初始化方法设置,但我不知道如何设置
let joint = SKPhysicsJointFixed.jointWithBodyA(node1.physicsBody, bodyB:node2.physicsBody, anchorA:nodea.position, anchorB:node2.position)
self.physicsWorld.addJoint(joint)
试试这个:
let joint = SKPhysicsJointFixed.jointWithBodyA(node1.physicsBody, bodyB:node2.physicsBody, anchorA:nodea.position, anchorB:node2.position)
self.physicsWorld.addJoint(joint)
对于Swift 3,答案是:
let fixedJoint = SKPhysicsJointFixed.joint(withBodyA: nodeA.physicsBody!, bodyB: nodeB.physicsBody!, anchor: anchorPoint)
self.physicsWorld.add(joint)
假设两个物理体都已设置。对于Swift 3,答案是:
let fixedJoint = SKPhysicsJointFixed.joint(withBodyA: nodeA.physicsBody!, bodyB: nodeB.physicsBody!, anchor: anchorPoint)
self.physicsWorld.add(joint)
假设两个物理体都已设置。锚应该在哪里?锚应该在哪里??