gpt4 book ai didi

ios - 无法设置 SKView backgroundColor

转载 作者:技术小花猫 更新时间:2023-10-29 10:39:31 24 4
gpt4 key购买 nike

我有一个问题,我的 SKView 的背景颜色(灰色)在场景出现之前短暂显示。

我试图通过 Storyboard 编辑器和我的 Controller (self.skView.backgroundColor = [SKColor blueColor]) 手动设置它,但它仍然是灰色的。这不是可以覆盖的属性吗?

更新#1

这里有一些关于发生的事情的解释:

  1. viewDidLoad 被调用,skView 呈现在屏幕上,背景为灰色(skView.scene 尚未设置)。
  2. 我加载了游戏的所有 Assets (大约需要 1 秒),在此期间灰色背景可见。
  3. 加载 Assets 后,我加载场景并呈现它(灰色屏幕被替换为场景内容)

View Controller

- (void)viewDidLoad
{
[self.activityIndicator startAnimating];
[self authenticatePlayer];

self.skView.backgroundColor = [SKColor blueColor];

// During this time the grey screen is visible as the assets are being loaded and take ~1 second
// self.skView.scene is NULL here so I cannot set the backgroundColor...

[GamePlayScene loadSceneAssetsWithCompletionHandler:^{
[self.activityIndicator stopAnimating];
self.activityIndicator.hidden = YES;

CGSize viewSize = self.skView.bounds.size;

self.gamePlayScene = [[GamePlayScene alloc] initWithSize:viewSize];
self.adView.autoresizingMask = UIViewAutoresizingFlexibleWidth;

[self.skView presentScene:self.gamePlayScene];

}];
...

最佳答案

恐怕您要么必须先完成最基本的设置(例如设置 backgroundColor),然后加载其余的场景,要么展示一个“正在加载”的场景,直到游戏场景加载完毕,然后替换它。

关于ios - 无法设置 SKView backgroundColor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22053035/

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