Game Development Reference
Game Building Blocks
The game DoodleDrop in Chapter 4 was written to be easy to understand if you're new
to cocos2d. If you're a more experienced developer, though, you probably noticed that
there's no separation of code—everything is in just one file. Clearly, that doesn't scale,
and if you're going to make bigger, more exciting games than DoodleDrop, you'll have
to find a suitable way to structure your code. Otherwise, you might end up with one
class driving your game's logic. The code size can quickly grow to thousands of lines,
making it hard to navigate and tempting to change anything from anywhere, very likely
introducing subtle and hard-to-find bugs.
Each new project demands its own code design. In this chapter, I introduce you to some
of the building blocks for writing more complex cocos2d games. You can then use the
code foundation laid out in this chapter to create the side-scrolling shooter game you'll
be building in the next few chapters.
Because this chapter contains lots of reference material, I concentrate on the relevant
code and omit the details of creating new cocos2d classes as shown in earlier chapters.
You may want to download the topic's source code at this point to see this chapter's pro-
jects in action. You can download the topic's source code from the topic's page on
Working with Multiple Scenes