iPad 模拟器上的 SKScene 问题未在 Xcode 11 beta 7 中填充屏幕 [英] Issues with SKScene on iPad simulator not filling screen in Xcode 11 beta 7

查看:29
本文介绍了iPad 模拟器上的 SKScene 问题未在 Xcode 11 beta 7 中填充屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Xcode 11 beta 7 中,我的 SKScene 出现问题,我的 GameScene 没有填满 iPad 模拟器的整个屏幕.这适用于所有 iPad 模拟器.在我的物理 iPad 上,游戏场景符合预期,但我担心这可能不适用于所有 iPad.在所有 iPhone 模拟器和我的 iPhone 上,游戏场景也按预期显示.

In Xcode 11 beta 7, I am having issues with my SKScene, my GameScene does not fill the entire screen of the iPad simulator. This is true for all iPad simulators. On my physical iPad the Game Scene is as intended, but I worry this may not be true of all iPad's. On all iPhone simulators and on my iPhone, the Game Scene is also displayed as intended.

我有两个 SKScenes,一个是填满整个屏幕的主菜单屏幕,但我的游戏场景没有,当我加载游戏场景时,它是方形的,主菜单屏幕可见在下面,像这样:

I have two SKScenes, one is the Main Menu screen which fills the entire screen, but my Game Scene does not, when I load the Game Scene it is square and the Main Menu screen is visible underneath, like so:

以下是我的 GameViewController 的代码,它与我的 MainMenuViewController 几乎相同,除了Game"的所有实例都是MainMenu":

The following is the code for my GameViewController, which is practically identical to my MainMenuViewController except all instances of "Game" are "MainMenu":

class GameViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Load 'GameScene.sks' as a GKScene. This provides gameplay related content
        // including entities and graphs.
        if let scene = GKScene(fileNamed: "GameScene") {

            // Get the SKScene from the loaded GKScene
            if let sceneNode = scene.rootNode as! GameScene? {

                // Copy gameplay related content over to the scene
                sceneNode.entities = scene.entities
                sceneNode.graphs = scene.graphs

                // Set the scale mode to scale to fit the window
                sceneNode.scaleMode = .aspectFill

                // Present the scene
                if let view = self.view as! SKView? {
                    view.presentScene(sceneNode)

                    view.ignoresSiblingOrder = true

                    view.showsFPS = true
                    view.showsNodeCount = true
                }
            }
        }
    }

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

我尝试将 sceneNode.scaleMode = .aspectFill 行更改为 sceneNode.scaleMode = .aspectFit,但这会产生以下结果:

I have tried changing the line sceneNode.scaleMode = .aspectFill to sceneNode.scaleMode = .aspectFit, but that produces the following:

那么,如何让我的游戏场景(红色区域)填满整个 iPad 屏幕?

So, how do I make my Game Scene, the red area, fill the entire iPad's screen?

推荐答案

通常在设置赏金后我会找到答案.

Typical that after setting a bounty I find the answer.

问题出在我的故事板文件中,而不是我的代码中:

The issue was in my storyboard file, not my code:

最初,我在转场后的视图属性中有这个:

Originally, I had this in the properties of my view after the segue:

把它改成这样会使 SKView 填满整个屏幕:

And changing it to this made the SKView fill the entire screen:

显然在某些时候 Xcode 发生了变化,因此无论出于何种原因,自动"不再填满屏幕.

Clearly at some point Xcode changed so that 'Automatic' no longer filled the screen for whatever reason.

更多说明,当您打开故事板文件时,单击/选择要调整的视图控制器,在属性检查器下,有一个用于演示的选项,您可以在其中选择全屏"属性.

For more clarification, when you open the storyboard file, click/select the view controller that you want to adjust, under the Attributes Inspector, there is an option for Presentation where you can select the "Full Screen" attribute.

这篇关于iPad 模拟器上的 SKScene 问题未在 Xcode 11 beta 7 中填充屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆