我有一個問題,我的SKView的背景色(灰色)在場景出現之前暫時顯示。無法設置SKView backgroundColor
我手動嘗試通過故事板編輯器和我的控制器(self.skView.backgroundColor = [SKColor blueColor]
)設置它,但它仍然是灰色的。這不是可以被覆蓋的屬性嗎?
更新#1
這裏的,以什麼發生一點解釋:
viewDidLoad
被調用,skView
呈現在屏幕上W/A灰色背景(skView.scene
尚未設定) 。- 我加載了遊戲的所有資產(大約需要1秒),在此期間灰色背景可見。
- 資產已經被加載後,我加載場景,目前它(灰幕被替換瓦特/場景的內容)
的ViewController
- (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];
}];
...
問題是'self.skView.scene'在短時間內爲空(請參閱我更新的問題)。 –
是的,就像GLKView一樣,SKView由CAEAGLLayer支持。這就是灰色來自的地方。改變這是可能的(這裏有一些答案),但我認爲這種情況有點矯枉過正。看看我更新的答案。 –