Game Development Reference
In-Depth Information
Figure 4-4 . Adding new CCNode-derived classes is best done using the class templates provided by cocos2d or Ko-
bold2D. In this case, you want the CCNode class to be a subclass of CCLayer because you're setting up a new scene
and layer
Because Cocos2d and Kobold2D provide class templates for the most important nodes
and classes, it'd be a shame not to use them. On the other hand, Xcode's own
Objective-C class template is also a very good template for new classes—you only
need to change the base class from NSObject to CCLayer manually. From the
cocos2d v2.x templates section, select the CCNode class, click Next, and make sure
it's set to Subclass of CCLayer before clicking Next again to bring up the Save File
dialog in Figure 4-5 .
I'm going to name the new file GameLayer.m . It's going to be the class where all of
the DoodleDrop game play logic takes place, so that name seems appropriate. Be sure
that the DoodleDrop target check box is checked (see Figure 4-5 ).
Note Not reviewing the target check boxes may incorrectly assign the newly
added file to the wrong target. This can lead to all kinds of issues—compile or
“file not found” errors are the typical result. Sometimes the game may crash
 
 
Search Nedrilad ::




Custom Search