Book Image

Building Android Games with Cocos2d-x

By : Raydelto Hernandez
Book Image

Building Android Games with Cocos2d-x

By: Raydelto Hernandez

Overview of this book

Table of Contents (16 chapters)
Building Android Games with Cocos2d-x
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating scenes


The scene concept is very important within the Cocos2d-x game engine, since all the displayed screens in our game are considered scenes. Creating an analogy between Cocos2d-x and the Android native Java development, we can say that a Cocos2d-x scene is equivalent to what Android calls activity.

In the previous chapter we introduced the AppDelegate class, and we explained that it has the responsibility of loading the framework on the device and then executing the game-specific code. This class contains the ApplicationDidFinishLaunching method, which is the entry point of our code. In this method, we instantiate the scene that is going to first be displayed in our game, and then request the director to load it, as we can see in the following code listing:

bool AppDelegate::applicationDidFinishLaunching() {
    auto director = Director::getInstance();
  // OpenGL initialization done by cocos project creation script
    auto glview = director->getOpenGLView();
    auto scene...