I am having difficulty writing my app in xCode. I am creating a game and I have a scene for the game, and a scene for a shop that I am working on. My line to go to the shop is
let transition2 = SKTransition.fadeWithColor(UIColor.greenColor(), duration: 1.0)
scene?.view?.presentScene(shopScene(), transition: transition2)
and this seems to work fine. But when I wish to transition back to the game scene, here is everything I have tried ( i commented it out so it wouldn't crash and I just stay on the shop scene)
// 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
and almost everything I try gets the error
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)
any help with this would be much appreciated.