Book Image

Learning Cocos2d-x Game Development

By : Siddharth Shekar
Book Image

Learning Cocos2d-x Game Development

By: Siddharth Shekar

Overview of this book

Table of Contents (19 chapters)
Learning Cocos2d-x Game Development
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Loading the menu scene at start of the app


To load the main menu scene instead of the HelloWorldScene on startup, open the AppDelegate.cpp file. Here on the top, include MainMenuScene.h. In the applicationDidFinishLaunching() function, find the following line of code:

CCScene *pScene = HelloWorld::scene(); 

Replace it with the following code:

CCScene *pScene = MainMenu::scene(); 

That is all; now if you build and run it, you will see the main menu loaded:

Now if you click on the play button, the game will start. How to go back to the main menu? We will add a button in the gameover() function, which will take us back to the main menu, but first let's create the option menu.