0

enter image description here

import UIKit
import SpriteKit
import GameplayKit

class GameViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        if let view = self.view as! SKView? {
            // Load the SKScene from 'GameScene.sks'
            if let scene = SKScene(fileNamed: "MenuScene") {
                // Set the scale mode to scale to fit the window
                scene.scaleMode = .aspectFill
                
                
                // Present the scene
                view.presentScene(scene)
            }
            
            view.ignoresSiblingOrder = true
            
            view.showsFPS = false
            view.showsNodeCount = false
        }
    }

    override var shouldAutorotate: Bool {
        return true
    }

    override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
        if UIDevice.current.userInterfaceIdiom == .phone {
            return .allButUpsideDown
        } else {
            return .all
        }
    }

    override var prefersStatusBarHidden: Bool {
        return true
    }
}

That is the code in my game view controller scene. I have tried aspect fill/fit in scene.scale mode but neither make any difference. Thanks for any help.

1 Answers1

0

Once again, this happens because Apple has mistakenly removed the launch screen from the iOS-only SpriteKit game template (it's still there in the multi-platform template). You need to either add and assign a launch screen or choose Main as your launch screen.

The launch screen defines the working area for the app, so without it the view bounds and scene scale mode will not fix this issue.

Man, this is really going to continue being an issue that people are stumped by. Quite an oversight on Apple's part!

More info in Background is not filling the whole view SpriteKit.

  • Thank you wonder why they haven't fixed it yet. My first scene has now been fixed but my second scene still does not fit the whole screen – Greg McKenna Mar 24 '21 at 20:13
  • I used up an apple dev support ticket on this very issue, frustrating they have not fixed it still. – JohnL Mar 24 '21 at 20:56