Game Development Reference
In-Depth Information
We will do the same for the second button, so hold
Shift
+ click on the two behaviors
here (the display text and rule) and copy them by pressing
Ctrl
+
C
(Windows), or
Command
+
C
(Mac). Now double-click on the second button, and then click on the
lock and paste the behaviors by pressing
Ctrl
+
V
or
Command
+
V
. Change the text
to
Continue
, and the
Change Scene
behavior from
Next Scene
to
At Index
. We are
going to create an integer that will save the player's current level, and when we click
on the
Continue
button, it will jump back to that level. Let's go back to our scene,
and in the
Inspector
section, select the
Attributes
tab, and click the
+
button. A pop
up will now display asking what type of attribute you want to create. Select
Integer
and click on
Choose
. Double-click on the name and change it to
Saved Level
, or
whatever you will remember.
Now test your game to see if the buttons work; the default integer for our
Saved
Level
is zero, so when you click on the
Continue
button nothing will happen. You
can check to see if it's working by changing that number from
0
to
1
. Now when you
click on the button, it should go back to the first scene.
Selecting levels
For this game, I'm not going to include a level selection menu. However, if you want
to create one, let me show you.
Let's start by creating a new scene. I'm going to start by arranging a bunch of buttons
in the scene. We will follow the same formula we used on the main menu, but each
button will load to a different level: