Game Development Reference
A positive benefit of this approach is that it makes selectively pausing certain objects
easier. How to pause the game but allow user input on the pause menu is a question
that comes up often. The solution is to update your layers individually, and if the game
is paused you don't forward the update message to the layers except for the layer that
displays the pause menu.
Director, Scenes, and Layers
Like CCNode , the CCScene and CCLayer classes have no visual representation and
are used internally as abstract concepts for the starting point of the scene graph, which
is always a CCScene -derived object. The CCScene class is the container for all other
nodes of the scene. And CCLayer is typically used to group nodes together, particu-
larly to maintain the correct drawing order among multiple layers. But also to receive
touch and accelerometer input In iOS, and mouse and keyboard input in Mac OS X.
I start this section with the CCDirector class, however, because it's the class that,
among other things, allows you to run and replace scenes.
The CCDirector class, or simply Director for short, is the heart of the cocos2d game
that a lot of the cocos2d initialization procedure involved calls to [CCDirector
The CCDirector class is a singleton, which means there can be only one instance of
the CCDirector class at any time, and it can be accessed globally by calling the
class method sharedDirector . For now that's all you need to know about
singletons. Later in this chapter, in the section “A Note on Singletons in cocos2d,” I ex-
plain what a singleton is and which other singleton classes cocos2d uses.