Book Image

Cocos2d-x by Example: Beginner's Guide

By : Roger Engelbert
Book Image

Cocos2d-x by Example: Beginner's Guide

By: Roger Engelbert

Overview of this book

Table of Contents (19 chapters)
Cocos2d-x by Example Beginner's Guide Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using scenes in Cocos2d-x


Scenes are mini applications themselves. If you have experience as an Android developer, you may think of scenes as activities. Of all the classes based on node, the Scene application is the most architecturally relevant, because the Director class runs a scene, in effect running your application.

Part of the benefit of working with scenes is also part of the drawback: they are wholly independent and ignorant of each other. The need to share information between scenes will be a major factor when planning your game class structure.

Also, memory management may become an issue. A currently running scene will not give up its ghost until a new scene is up and running. So, when you use transition animations, keep in mind that for a few seconds, both scenes will exist in memory.

In Eskimo, I initialize scenes in two different ways. With MenuLayer and LevelSelectLayer, each time the user navigates to either one of these scenes, a new layer object is created (either a new MenuLayer...