Game Development Reference
In-Depth Information
connected device or the iOS Simulator, depending on which run target is selected in the
toolbar. You should see the exact same scene you saw in SpriteBuilder seconds before on
your device or the iOS Simulator.
Tip If you haven't used Xcode before and need more instructions on how to
use it, you should consult the Xcode Guide available via Help Xcode Over-
view or online at https://developer.apple.com/library/ios/
documentation/ToolsLanguages/Conceptual/
Xcode_Overview .
First Scene, First Code
The first goal is to create a second scene and then connecting buttons so you can switch
back and forth between the two scenes. This second scene is going to be the game scene,
while the existing MainScene will become the menu screen. This is a commonplace, rudi-
mentary separation between game and menu scenes.
A scene contains all the content (nodes) that the game currently renders. Other scenes can
replace the currently visible scene using transitions, just like Cocoa touch views can trans-
ition from one view to another with or without animations.
Note A common misconception is that scenes and nodes can be used inter-
changeably with views. This is not so. Cocos2D has its own UIView class
named CCGLView that renders all the scenes and nodes using OpenGL instruc-
tions. Therefore, other UIView instances can be either entirely on top of or be-
hind the Cocos2D view and the scene it currently displays.
Creating the GameScene
Go to File New File, or right-click the Project Navigator pane below the preview
area and choose New File from the context menu to create a new SpriteBuilder document
file, also known as a CCB file . Select the Scene type, and enter GameScene.ccb as the file
name (as shown in Figure 2-4 ) and click the Create button.
Search WWH ::




Custom Search