swiftsprite-kitskscene

SpriteKit SKScene not resizing correctly to fit iPhone 12


I've created a new SpriteKit project and want the scene to fill the screen entirely. I have defined the GameScene with iPhone 12 screen dimensions (390pt x 844pt) and specified the following in GameViewController.swift:

if let view = self.view as! SKView? {
    if let scene = SKScene(fileNamed: "GameScene") {
        scene.scaleMode = .aspectFill
        view.presentScene(scene)
    }
}

However, there is still a large amount of unoccupied space above and below the SKScene. I can't figure out what I've done wrong, and any help would be appreciated.

Simulator screenshot


Solution

  • Fix (credit @aheze)

    As mentioned here, this can be fixed by setting the launch screen file in your project settings under App Icons and Launch Images.