scaleMode .fill not filling the scene view on iPad

2019-07-28 13:17发布

问题:

I created my game using the Universal images of dimensions 1136x640 (@2x) and 2208x1242 (@3x) for my start background. I changed the scaleMode property to .fill for iPad but it just fills the center with black borders all around. I thought .fill was suppose to extend the width and height to fill the scene view. I found a sample universal project that I tested and the images scaled with .fill for the iPad. They used, 568x320 (@1x), 1136x640 (@2x) and 1704x960 (@3x) for their images. I copied the images into my project and tested for iPad and still got the black surrounding.

  1. What is causing the black border for the iPad?

  2. What explicit dimensions should I use for my universal game for @1x, @2x, @3x background so that when I set scaleMode to .fill for iPad it will fill the scenes width and height?

Below is my how I set the StartBackgroundScene scene in the GameViewController

    override func viewWillLayoutSubviews() {
    super.viewWillLayoutSubviews()

    let skView = self.view as? SKView

    if skView?.scene == nil  {
        skView?.showsFPS = true
        skView?.showsNodeCount = true
        skView?.showsPhysics = false
        skView?.ignoresSiblingOrder = false

        let startBackgroundScene = StartBackgroundScene(size: skView!.bounds.size) 
        startBackgroundScene.scaleMode = .fill
        skView?.presentScene(startBackgroundScene)
    }