gpt4 book ai didi

ios - gameViewController 背景颜色无法更改

转载 作者:行者123 更新时间:2023-11-28 06:12:56 25 4
gpt4 key购买 nike

运行在spriteKit下的App。几天前,一旦 gameViewController 被加载,gameScene 就会被加载。今天我把它的加载 Action 改成只有在点击开始按钮时才加载gameScene,也就是说gameScene的背景色是不可见的,我需要给gameViewController设置一个背景色。这是一项非常非常简单的任务,需要多次完成 以前,但它坚持浅灰色(下图)。

在spriteKit下gameViewController背景颜色不能改吗?

我必须改为更改 gameScene 背景颜色吗?

    override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = .green

// .......
}

@IBAciton func loadGameView() {
if let view = self.view as! SKView? {
// Load the SKScene from 'GameScene.sks'
// if let scene = SKScene(fileNamed: "GameScene") {
if let scene = GameScene(fileNamed: "GameScene") {
scene.viewController = self
scene.size = self.view.frame.size
scene.scaleMode = .aspectFill
// Present the scene
view.presentScene(scene)

}

view.ignoresSiblingOrder = false
view.showsFPS = false
view.showsNodeCount = false
view.showsDrawCount = false


}

}

enter image description here

最佳答案

    if let scene = GameScene(fileNamed: "GameScene") {
scene.viewController = self
scene.size = self.view.frame.size
scene.scaleMode = .aspectFill

//ADD THIS
scene.color = .green
scene.colorBlendFactor = 1

// Present the scene
view.presentScene(scene)

}

关于ios - gameViewController 背景颜色无法更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45974718/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com