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.