How to reset a scene?
You just need to re-introduce the same new scene whenever you want. So, you are all well.
Possible leakage problems?
In addition, if you do not have leaks in your game, then there are no strong reference loops, you do not even need self.removeAllChildren() and self.removeAllActions() ... Of course, if you explicitly want to stop actions before transitional animation begins, use This method makes sense. The fact is that when a scene is freed, all objects that depend on it should / will also be freed.
However, if you do not know from the very beginning what you are doing and how to prevent the leak, for example. you use a strong self in a block, which is part of a sequence of actions that repeats forever, then you probably have a leak, and self.removeAllActions() can help (in many cases, but this is not the final solution). I would recommend reading about capture lists and ARC in general, because it might be useful to know how all this works just because of these situations.
The scene is the root of the node
The call to removeFromParent() in the scene itself has no effect. A scene is the root of a node, so it cannot be deleted in the current context. If you check the parent property of the scene, you will notice that it is zero. Of course, you can add a scene to another scene, but in this case, the scene added as a child will act like a normal node.
And finally, how to introduce a new scene? Easy, like this:
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { let newScene = GameScene(size: self.size) newScene.scaleMode = self.scaleMode let animation = SKTransition.fade(withDuration: 1.0) self.view?.presentScene(newScene, transition: animation) }
If something does not work for you, it is likely that you have leaks (which means your scene is not released). To test this, somewhere in your GameScene override method, for example:
deinit{print("GameScene deinited")}
To explain it to you a little further ... What should happen is that you have to introduce a new scene, a transition must take place, the old scene must be released, and you should see a new scene with the initial state.
Also, overriding deinit will just tell you if the scene is freed properly or not. But that will not tell you why. It is up to you to find the scene in your code.