当我更改 GameScene 的 anchorPoint 时,屏幕上(from default 0,0 to 0.5,0.5)
的 sprite 的物理体。disappeared
debugging with kView.showsPhysics = true
它仍然存在,因为每艘船都相互碰撞,但看起来physicsBody 的位置发生了偏移(超出屏幕)。
为什么此更改会影响场景子对象的物理体?
class GameScene: SKScene {
override func didMoveToView(view: SKView) {
anchorPoint = CGPointMake(0.5, 0.5)
physicsWorld.gravity = CGVector(0, 0)
}
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
for touch: AnyObject in touches {
let location = touch.locationInNode(self)
let sprite = SKSpriteNode(imageNamed:"Spaceship")
sprite.physicsBody = SKPhysicsBody(circleOfRadius: 100)
sprite.xScale = 0.5
sprite.yScale = 0.5
sprite.position = location
let action = SKAction.rotateByAngle(CGFloat(M_PI), duration:1)
sprite.runAction(SKAction.repeatActionForever(action))
self.addChild(sprite)
}
}
}