1
试图让我的SKSpriteNode停留在使用edgeLoopFromRect:view.frame的只有肖像的布局框架内,并且它仅从框架的左侧反弹,仍然留下间隙....physicsBody = SKPhysicsBody(edgeLoopFromRect:view.frame)
试图用 “视图”,edgeLoopFromRect:框架,它飞走了屏幕...
任何帮助,将不胜感激..
func makeShip() {
let ship = playerShip
ship.position = CGPoint(x: frame.size.width/2, y: frame.size.height/2)
ship.physicsBody = SKPhysicsBody(rectangleOfSize: ship.frame.size)
ship.physicsBody!.dynamic = true
ship.physicsBody!.affectedByGravity = false
ship.physicsBody!.mass = 0.08
addChild(ship)
}
override func didMoveToView(view: SKView) {
makeShip()
physicsBody = SKPhysicsBody(edgeLoopFromRect: view.frame)
motionManager.startAccelerometerUpdates()
}
有两个问题。你有没有尝试将'ship'物理体设置为'rectangleOfSize:ship.size'?我不确定你是否在寻找框架(随时纠正我)。并且您是否尝试过'ship.physicsBody!.usesPreciseCollisionDetection = true'以确保船舶无法通过边界弹出? – Gliderman
是的,我通过binarysubstrate –