Xcode Swift无法返回游戏场景

时间:2016-04-25 23:07:42

标签: swift transition scenekit sknode

我在xCode中编写应用程序时遇到了困难。我正在创建一个游戏,我有一个游戏场景,以及我正在处理的商店的场景。我去商店的路线是

let transition2 = SKTransition.fadeWithColor(UIColor.greenColor(), duration: 1.0) scene?.view?.presentScene(shopScene(), transition: transition2)

这似乎工作正常。但是,当我希望转换回游戏场景时,这里是我尝试过的所有内容(我对此进行了评论,因此它不会崩溃,我只是留在商店场景中)

// shopScene.removeFromParent(self.scene) // self.shopScene.removeFromParent() // self.view?.presentScene(GameScene()) // let gameScene = GameScene(size: theView.bounds.size) // gameScene.scaleMode = SKSceneScaleMode.ResizeFill // theView.presentScene(gameScene) //scene?.view?.willMoveToSuperview(GameViewController()) // scene?.view. //scene?.view?.presentScene(GameScene()) //scene?.view?.presentScene(GameScene()) // let desiredScene = GameScene2(size: (self.view?.scene?.size)!) // self.scene?.removeFromParent() // self.scene?.view?.removeFromSuperview() // self.scene?.view?.presentScene(GameScene2()) //self.scene?.view?.willMoveToSuperview(GameScene2()) //self.scene?.hidden = true

我几乎所有尝试都会收到错误

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Attemped to add a SKNode which already has a parent: <SKNode> name:'(null)' position:{0, 0} scale:{1.00, 1.00} accumulatedFrame:{{0, 0}, {0, 0}}' *** First throw call stack: (0x180fc6e38 0x18062bf80 0x180fc6d80 0x18eede438 0x18eede364 0x1000e93d8 0x1000efbd4 0x18eeb14e0 0x18eece278 0x1000e6260 0x1000e62dc 0x18eeb14e0 0x18eece278 0x1000fa96c 0x1000faaf0 0x18eecccec 0x186147dc0 0x186140b08 0x186110f4c 0x18610f528 0x180f7d124 0x180f7cbb8 0x180f7a8b8 0x180ea4d10 0x18278c088 0x186179f70 0x1000fd130 0x180a428b8) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)

对此的任何帮助都将非常感激。

0 个答案:

没有答案