Game Development Reference
In-Depth Information
along with documentation, the names of methods and properties and other de-
tails of the class.
Now that you know how to the start scene in AppDelegate and how to change scenes
when tapping a button, run the app and try it if you haven't done so yet—I'll leave it as an
exercise to change the starting scene back to the MainScene and to add another button
on the MainScene . So that, when the button in the MainScene is tapped, it transitions
to the GameScene . An example of this project state is provided with the topic in the 01 -
Change Scenes with Buttons folder.
Creating a Level Sub File Node
Back to SpriteBuilder—specifically, the GameScene.ccb file. The game we're building
should support multiple levels. Because each level will have the same basic game play, it
makes sense to reuse the GameScene.ccb for each level so that you don't have to re-im-
plement common features in each level separately. For instance, the HUD or heads-up dis-
play—a misnomer, but a commonly used term that refers to any nonscrolling content, like
pause buttons and score labels in a scrolling world.
This is where the Sub File node comes in handy. It allows you to create template CCB
files that can be instantiated multiple times and edited in a single file. Consider the Sub
File node being the equivalent of a class in Objective-C. The GameScene will have three
Sub File nodes, one for the actual level contents, one for the HUD layer, and one for any
popovers like the pause and “game over” menus.
Since re-organizing resources at a later point is tedious and error prone, it's important to
start with a project structure that can grow with the project. For this exercise, start by
adding a new folder named Levels to the project, where all the game's level files will be
added to. You can create a folder via the File New Folder menu or by right-click-
ing in the Resource Navigator view on the lower left half of the File View tab—that's
where the CCB files and other resources are listed.
First, create a CCB that will contain the level's nodes. Since a level needs a specific size,
in this case to determine the scrollable area of the world, the Layer document type is the
right choice. Select the Levels folder before you issue the File New File command,
and before you right-click the Levels folder and select New File. This will display the dia-
log in Figure 2-13 .
Search WWH ::




Custom Search