HTML and CSS Reference
Figure 24-1. Example game flow
A Cocos2d cc.Scene is composed of one or more cc.Node objects, added as children to the scene. Subclasses of
cc.Node , such as cc.Layer and cc.Sprite , give the scene its appearance and behavior. Typically, you implement your
screens as subclasses of cc.Layer and add them to a blank instance of cc.Scene . Afterwards, you implement your
other graphics and game objects as cc.Node and add them as children to the cc.Layer you created.
Because scenes are a subclass of cc.Node , they can be transformed manually or programatically by using
cc.Action . See Actions at http://cocos2d-x.org/wiki/Actions for more information.
There is also a family of cc.Scene classes called transitions , implemented with the cc.TransitionScene class.
These allow you to create special transition effects when switching from one scene to another, such as fading, and
sliding in from the side.
A cc.Layer is a cc.Node , and it is often used as a container for displayable elements. Layers know how to draw
themselves and may be semi-transparent, allowing players to see other layers behind them. cc.Layer is very useful in
defining your game's appearance and behavior, so expect to spend a considerable amount of your programming time
coding cc.Layer subclasses. A series of Cocos2d layers in a regular menu scene are shown in Figure 24-2 .
Figure 24-2. Cocos2d layers