Developers Manual > Cocos2d-x > Modules > Scene Graph > Scene

Scene

A scene (implemented with the CCScene object) is more or less an independent piece of the app workflow. Some people may call them “screens” or “stages”. Your app can have many scenes, but only one of them is active at a given time.

For example, you could have a game with the following scenes: Intro, Menu, Level 1, Cutscene 1, Level 2, Winning cutscene, losing cutscene, High scores screen. You can think of each one of these scenes as a separate application that can be connected to other scenes with a small amount of “glue” code. For example, the intro scene might go to the menu scene when it finishes, and the scene for Level 1 might lead to cutscene 1 (if the player wins) or to the losing cutscene (if the player loses). An example of how scenes might flow in a game follows:

A cocos2d CCScene is composed of one or more CCNodes, added as children to the scene. Subclasses of CCNode, such as CCLayer and CCSprite, give the scene its appearance and behavior. Typically, you implement your screens as subclasses of CCLayer and add them to a blank instance of CCScene. Then, implement your other graphics and game objects as CCNodes and add them as children to the CCLayer you created.

Because scenes are a subclass of CCNode, they can be transformed manually or by using CCActions. See Actions for more information.

There is also a family of CCScene classes called transitions, implemented with the CCTransitionScene class. These allow you to create special transition effects when switching from one scene to another—for example, fading, sliding in from the side, and so on.

Sign up for our newsletter to keep up with the latest developments, releases and updates for Cocos2d-x.