Game Development Reference
In-Depth Information
The CCDirector class stores global configuration settings for cocos2d and also man-
ages the cocos2d scenes. The major responsibilities of the CCDirector class include
the following:
▪ Providing access to the currently running scene
▪ Changing scenes
▪ Providing access to cocos2d configuration details
▪ Providing access to cocos2d's OpenGL view and window
▪ Modifying certain OpenGL projection and enabling depth tests
▪ Converting UIKit and OpenGL coordinates
▪ Pausing, resuming, and ending the game
▪ Displaying debugging stats
▪ Counting the total number of frames rendered
In earlier cocos2d versions you could also choose between several Director types.
That's no longer the case in cocos2d 2.0. The CCDirector now uses Apple's
CADisplayLink class exclusively to synchronize screen updates with the display's
refresh rate.
CCScene
A CCScene object is always the first node in the scene graph. In cocos2d, a scene is
an abstract concept, and the CCScene class contains virtually no additional code com-
pared to CCNode . But the CCDirector requires a CCScene -derived class to be able
to change the currently active scene graph via the CCDirector runWithScene ,
replaceScene , and pushScene methods. You can also wrap a CCScene class in-
to a class derived from CCSceneTransition to animate the transition between a
currently running scene and the new scene.
Normally, the only children of a CCScene are those derived from CCLayer , which in
turn contain the individual game objects, although this convention is not enforced by
cocos2d. Because the scene object itself in most cases doesn't contain any game-spe-
cific code and is rarely subclassed, it's most often created in a static method +(id)
Search Nedrilad ::




Custom Search