【问题标题】:How to make the scene stretch out fully to the width. Screenshot attached of my Xcode simulator of it not filling the screen如何使场景完全伸展到宽度。附上我的 Xcode 模拟器的屏幕截图,它没有填满屏幕
【发布时间】:2021-03-24 19:43:01
【问题描述】:

enter image description here

import UIKit
import SpriteKit
import GameplayKit

class GameViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        if let view = self.view as! SKView? {
            // Load the SKScene from 'GameScene.sks'
            if let scene = SKScene(fileNamed: "MenuScene") {
                // Set the scale mode to scale to fit the window
                scene.scaleMode = .aspectFill
                
                
                // Present the scene
                view.presentScene(scene)
            }
            
            view.ignoresSiblingOrder = true
            
            view.showsFPS = false
            view.showsNodeCount = false
        }
    }

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

这是我的游戏视图控制器场景中的代码。我已经尝试在 scene.scale 模式下填充/适合,但都没有任何区别。感谢您的帮助。

【问题讨论】:

    标签: ios swift xcode sprite-kit


    【解决方案1】:

    再次发生这种情况是因为 Apple 错误地从仅适用于 iOS 的 SpriteKit 游戏模板中删除了启动屏幕(它仍然存在于多平台模板中)。您需要添加和分配启动屏幕,或者选择 Main 作为启动屏幕。

    启动屏幕定义了应用的工作区域,因此如果没有它,视图边界和场景缩放模式将无法解决此问题。

    伙计,这确实会继续成为人们难以解决的问题。苹果方面的疏忽!

    Background is not filling the whole view SpriteKit 中的更多信息。

    【讨论】:

    • 谢谢你想知道为什么他们还没有修复它。我的第一个场景现在已经修复了,但我的第二个场景仍然不适合整个屏幕
    • 我在这个问题上用完了苹果开发支持票,令人沮丧的是他们还没有修复它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-26
    • 2020-11-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多