O'Reilly logo

Cocos2d-x Game Development Essentials by Gareth Jones, Arutosh Gurung, Frahaan Hussain

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Coding the menus in the Game Over scene

The Game Over scene requires a menu system to restart the game and to go back to the main menu. Menu item images will be used to display the buttons that the user can interact with to perform the actions mentioned.

Add the following code to the init() method:

auto menuTitle = MenuItemImage::create("GameOverScreen/Game_Over.png", "GameOverScreen/Game_Over.png"); auto retryItem = MenuItemImage::create("GameOverScreen/Retry_Button.png", "GameOverScreen/Retry_Button(Click).png", CC_CALLBACK_1(GameOver::GoToGameScene, this)); auto mainMenuItem = MenuItemImage::create("GameOverScreen/Menu_Button.png", "GameOverScreen/Menu_Button(Click).png", CC_CALLBACK_1(GameOver::GoToMainMenuScene, this)); auto menu = Menu::create(menuTitle, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required