Game Development Reference
In-Depth Information
Adding a Static Game Menu Layer
The game menu layer will be the node that contains all of the in-game user interface con-
trols and labels. For now, you need it just to add a pause button, but it could also contain a
score label, a countdown timer, the player's health bar, a virtual joypad, buttons to activate
special abilities, or just about any other user interface element that shouldn't scroll along
with the level.
All of the user interface elements should be in their own folder, just like the prefabs. Your
first task is to add a new folder in SpriteBuilder's File View and name it UserInterface .
Then right-click the UserInterface folder and select New File to create a new CCB docu-
ment. Name this document GameMenuLayer.ccb , and set its type to Layer . Leave the
size at the default 568x384, and click Create .
Aligning a Button with Reference Corners
Drag and drop a Button node from the Node Library View onto the GameMenuLayer.ccb
stage. Drag and move the button so that it is very close, if not touching, the upper-left
corner of the layer.
Next, open GameScene.ccb and drag and drop the GameMenuLayer from the Tileless Ed-
itor View onto the stage. Then verify that its position property is set to 0,0.
Switch to Phone resolution by pressing Cmd+1 in case you are viewing GameScene.ccb in
iPad resolution. Notice how the button is only partially visible or not visible at all.
Caution When viewing a CCB file that includes another CCB file via a Sub
File node, you must save the CCB file referenced by the Sub File node in order
to see its most recent edits.
In this instance, the GameMenuLayer.ccb is included via a Sub File node in the
GameScene.ccb . Whenever you make a change to GameMenuLayer.ccb , you
have to do File Save while viewing the GameMenuLayer.ccb or publish the
project in order to see its current state in the GameScene.ccb .
Use the Document Resolution Tablet Landscape and Document Resolution
Phone Landscape menu items to switch between iPad and iPhone screen sizes on the fly.
Or more easily, just press Cmd+1 and Cmd+2 to toggle between the available resolutions.
CCB files of type Scene also offer a Phone Landscape (short) (Cmd+3) resolution repres-
enting 3.5-inch iPhones up to iPhone 4S.
Search WWH ::




Custom Search