Game Development Reference
In-Depth Information
With the root node selected, enter GameScene in the Custom class field like in Figure
2-9 . Be sure the case matches, too. If you enter “gamescene” in the custom class text field
but name your class “GameScene,” the code connection is not going to work. You also
have to use a valid Objective-C class name. If in doubt, just stick to letters and numbers
and don't start the class name with a number, and you'll be fine.
Figure 2-9 . GameScene.ccb root node with custom class assigned
Now switch over to Xcode. You should still have the project open. If not, go to File
Open Recent, and select the project from the list, or double-click the .xcodeproj in Finder
as mentioned earlier.
Select the “Source” group in the project, and perform File New File from the
menu, or right-click and select New File from the context menu. Select the Cocoa Touch
Class (Xcode 5: Objective-C Class) template from the list of items shown in Figure 2-10
before clicking Next .
Figure 2-10 . Xcode file templates dialog
Name your class exactly as you did in SpriteBuilder. In this instance, it must be named
GameScene as shown in Figure 2-11 . Make it a subclass of CCNode , not CCScene , be-
Search WWH ::




Custom Search