scaleMode .fill not filling the scene view on iPad

£可爱£侵袭症+ 提交于 2019-12-11 07:15:48

问题


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)
    }

来源:https://stackoverflow.com/questions/40789050/scalemode-fill-not-filling-the-scene-view-on-ipad

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!