我有一个问题,我的SKView的背景颜色(灰色)是简短地显示在场景出现之前。
我试图手动设置它,无论是通过故事板编辑器还是在我的控制器(self.skView.backgroundColor = [SKColor blueColor]),但它仍然是灰色的。这不是一个可以重写的属性吗?
更新#1
下面是对发生的事情的一个小小的解释:
viewDidLoad,并在屏幕w/ a灰色背景上显示skView (skView.scene尚未设置)。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];
}];
...发布于 2014-02-26 21:52:10
恐怕您必须用完成的最基本的设置(比如设置backgroundColor)来呈现场景,然后加载其余的场景,或者在游戏场景加载之前呈现一个“加载”场景,然后替换它。
发布于 2014-02-26 21:23:03
我想你把它误认为是同名的SKScene属性
self.scene.backgroundColor = [SKColor blueColor];请注意,在将节点作为子节点分别添加到另一个节点(即已经是场景图的一部分)之前,self.scene (也是self.view)将为零,直到场景出现。
发布于 2014-02-26 21:23:06
您应该能够在呈现视图控制器viewDidLoad中设置viewDidLoad背景颜色--在呈现视图之前。这不是真的吗?
如果您已经将它添加到父节点中
https://stackoverflow.com/questions/22053035
复制相似问题