GameScene.swift:
override func didMoveToView(view: SKView) {
self.backgroundColor = SKColor.whiteColor()
self.player = SKSpriteNode(imageNamed:"player")
self.player.position = CGPointMake(100, 100)
self.player.size = CGSize(width: self.player.size.width*2, height: self.player.size.height*2)
self.addChild(self.player)
}
GameViewController.swift:
override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
if let scene = GameScene.unarchiveFromFile("GameScene") as? GameScene {
// Configure the view.
let skView = self.view as SKView
skView.showsFPS = false
skView.showsNodeCount = false
/* Sprite Kit applies additional optimizations to improve rendering performance */
skView.ignoresSiblingOrder = true
/* Set the scale mode to scale to fit the window */
scene.size = skView.bounds.size
scene.scaleMode = .AspectFill;
skView.presentScene(scene)
}
}
在iPhone 4S上,播放器正确地在屏幕上绘制 但是一旦在iPhone 5 / 5s上运行,播放器被绘制在屏幕下方,只能看到spritenode的一半
iPhone 4S:答案 0 :(得分:2)
听起来这可能是您选择SKSceneScaleMode
的问题,具体而言,听起来您可能选择了调整大小填充比例模式。将此更改为SKSceneScaleModeAspectFill
应足以解决此问题。