Scenes
Scenes in Cocos2d are used extensively to break the game into manageable components. While it would be possible to create your entire game in one scene, it is certainly not advisable. The scene is the root node of your node hierarchy. Each scene is a subclass of the CCNode
class. Only one scene can be active at any time, and changing the active scene is managed by the CCDirector
class .
Scene life cycle
Cocos2d provides multiple events that are called at certain points in the life cycle of your scene. You can override these events in any CCNode
subclass, and not just the CCScene
class. The following events are available:
init
: This method is called when a scene is initialized in code. If the scene was created in SpriteBuilder, this method is not called. This method is normally where you build your scene by adding child nodes.didLoadFromCCB
: This method is called when your scene is created in SpriteBuilder. It is called when the complete scene is loaded and all the code connections have...