iPad 模拟器上的 SKScene 问题未在 Xcode 11 beta 7 中填满屏幕
Issues with SKScene on iPad simulator not filling screen in Xcode 11 beta 7
在 Xcode 11 beta 7 中,我的 SKScene
有问题,我的 GameScene 没有填满 iPad 模拟器的整个屏幕。所有 iPad 模拟器都是如此。在我的身体 iPad 上,游戏场景符合预期,但我担心这可能并非对所有 iPad 都是如此。在所有 iPhone 模拟器和我的 iPhone 上,游戏场景也按预期显示。
我有两个 SKScenes
,一个是充满整个屏幕的主菜单屏幕,但我的游戏场景没有,当我加载游戏场景时它是方形的,主菜单屏幕在下面可见,像这样:
以下是我的 GameViewController
的代码,除了 "Game" 的所有实例都是 "MainMenu":
外,它几乎与我的 MainMenuViewController
相同
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
,但结果如下:
那么,如何让我的游戏场景(红色区域)填满整个 iPad 屏幕?
通常在设置赏金后我会找到答案。
问题出在我的故事板文件中,而不是我的代码中:
最初,我在 segue 之后的视图属性中有这个:
并将其更改为使 SKView 填满整个屏幕:
显然在某些时候 Xcode 发生了变化,因此 'Automatic' 出于某种原因不再填满屏幕。
编辑:为了更清楚地说明,当您打开故事板文件时,click/select 您要调整的视图控制器,在属性检查器下,有一个 Presentation 选项,您可以在其中 select "Full Screen" 属性。
在 Xcode 11 beta 7 中,我的 SKScene
有问题,我的 GameScene 没有填满 iPad 模拟器的整个屏幕。所有 iPad 模拟器都是如此。在我的身体 iPad 上,游戏场景符合预期,但我担心这可能并非对所有 iPad 都是如此。在所有 iPhone 模拟器和我的 iPhone 上,游戏场景也按预期显示。
我有两个 SKScenes
,一个是充满整个屏幕的主菜单屏幕,但我的游戏场景没有,当我加载游戏场景时它是方形的,主菜单屏幕在下面可见,像这样:
以下是我的 GameViewController
的代码,除了 "Game" 的所有实例都是 "MainMenu":
MainMenuViewController
相同
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
,但结果如下:
那么,如何让我的游戏场景(红色区域)填满整个 iPad 屏幕?
通常在设置赏金后我会找到答案。
问题出在我的故事板文件中,而不是我的代码中:
最初,我在 segue 之后的视图属性中有这个:
并将其更改为使 SKView 填满整个屏幕:
显然在某些时候 Xcode 发生了变化,因此 'Automatic' 出于某种原因不再填满屏幕。
编辑:为了更清楚地说明,当您打开故事板文件时,click/select 您要调整的视图控制器,在属性检查器下,有一个 Presentation 选项,您可以在其中 select "Full Screen" 属性。