The presence of a single viewing controller and multiple scenes
You can use one view controller (which is actually the default state of the SpriteKit game template) and have multiple scenes.
So, you will have GameViewController and LandingScene , GameScene and some other scenes are possible, for example, LevelSelect script or something like that.
In GameViewController you initialize your scene for the first time. So this is where you initialize your LandingScene (I think this is the place where you implemented your navigation menu).
So, from now on, you can make the transition from any scene you want using the SKView's presentScene: method (and optionally using the SKTransition class).
Transition
The transition to SpriteKit can be done mainly in two ways:
1. Some may tell you that the transition from the current scene to the next scene is a “bad design” and that the current scene should notify the view manager of its readiness for the transition state, so that the view controller can make the necessary transition. But in response to this, these are quotes from the docs:
Transition between two scenes
Typically, you move on to a new scene based on gameplay or user input. For example, if a user clicks a button in the main menu of a scene, you can switch to a new scene to adjust the match the player wants to play.
And related code:
- (void)mouseUp:(NSEvent *)theEvent { [self runAction: self.buttonPressAnimation]; SKTransition *reveal = [SKTransition revealWithDirection:SKTransitionDirectionDown duration:1.0]; GameConfigScene *newScene = [[GameConfigScene alloc] initWithSize: CGSizeMake(1024,768)]]; [self.scene.view presentScene: newScene transition: reveal]; }
You can clearly see that the transition to the next scene is performed in the current scene.
2. Using the method described above using the delegation template, where the scene delegates responsibility for the transition to the view controller.
Both methods are great, where the first method is a little convenient for IMO and is widely used. This way you can easily navigate between different scenes in SpriteKit .
Hint:
Remember to override the dealloc scene (or deinit if you use Swift) at design time to make sure all scenes are freed correctly.