Exit the Map and Load the Next Scene

Apple Game Frameworks and Technologies — by Tammy Coron (145 / 193)

The Pragmatic Programmers
The Pragmatic Programmers

--

👈 Save and Load Game Data | TOC | Create Additional Game Scenes 👉

As cool-looking as your game scene is right now, players will quickly get bored if they have to keep playing the same level. To add a little challenge to the game, and to make it more interesting, you can add multiple levels.

At the moment, Val’s Revenge has only one level and no way for players to even reach another level. You’re about to change that.

Adding an Exit Node

Switch to the GameScene_1.sks file and add a new Color Sprite to the scene. With the newly added sprite selected, open the Attributes Inspector. Name the new sprite exit, set its Texture to exit and its position to (X: 630, Y: 200).

Switch to the Components Inspector and add the PhysicsComponent component with the following settings:

  • bodyCategory: exit
  • bodyShape: rect

Also, drag the player node to the bottom of the Scene Graph View so that it appears on top of the exit node when the player moves over it.

When you’re done, your scene will look like this:

images/AddingMoreScenesAndSavingTheGame/exit-scene.png

--

--

The Pragmatic Programmers
The Pragmatic Programmers

We create timely, practical books and learning resources on classic and cutting-edge topics to help you practice your craft and accelerate your career.