skView.ignoreSiblingOrder = true初始化场景时,它有多重要/有效?
现在,我把它设置为true,但出于某种原因,当我从MainMenu场景开始我的GameScene时,它会在我的角色之前加载背景(即使背景的代码是第一个),但是一旦我死了它就会修复并返回到主菜单然后加载另一个游戏场景.为了避免这个问题,我制作了一个布尔值,它基本上可以检测我何时玩过多个游戏.它现在功能但非常难看,我确信有更好的方法.
代码:(在touchesBegan)
let skView = self.view as SKView!
skView.showsFPS = true
skView.showsNodeCount = true
if spriteNode.name == "StartButton"
{
/* Sprite Kit applies additional optimizations to improve rendering performance */
//sets ignoreSiblingOrder to false the first game because of XCode Glitch where background was rendering over player for some reason
skView.ignoresSiblingOrder = false
if(Game){
skView.ignoresSiblingOrder = true
}
if let scene = GameScene.unarchiveFromFile("GameScene") as? GameScene
{
skView.presentScene(scene)
/* Set the scale mode to scale to fit …Run Code Online (Sandbox Code Playgroud)