physicsBody = SKPhysicsBody(edgeLoopFromRect: view.frame)
physicsBody = SKPhysicsBody(edgeLoopFromRect: view.frame)
尝试使用 edgeLoopFromRect 使我的 SKSpriteNode 停留在仅纵向布局的框架内:view.frame,并且它仅从框架的左侧反弹并且仍然留下间隙....
尝试使用 "view",edgeLoopFromRect: frame,它飞出了屏幕...
任何帮助将不胜感激..
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()
}
在 override func didMoveToView(view: SKView)
中尝试添加:
let borderBody = SKPhysicsBody(edgeLoopFromRect: self.frame)
borderBody.friction = 0
self.physicsBody = borderBody
尝试使用 edgeLoopFromRect 使我的 SKSpriteNode 停留在仅纵向布局的框架内:view.frame,并且它仅从框架的左侧反弹并且仍然留下间隙....
尝试使用 "view",edgeLoopFromRect: frame,它飞出了屏幕...
任何帮助将不胜感激..
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()
}
在 override func didMoveToView(view: SKView)
中尝试添加:
let borderBody = SKPhysicsBody(edgeLoopFromRect: self.frame)
borderBody.friction = 0
self.physicsBody = borderBody