O'Reilly logo

Cocos2D Game Development Essentials by Ben Trengrove

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required