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 Pause scene

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

Add the following code to the init() method:

auto resumeItem = MenuItemImage::create("PauseScreen/Resume_Button.png", "PauseScreen/Resume_Button(Click).png", CC_CALLBACK_1(PauseMenu::Resume, this)); auto retryItem = MenuItemImage::create("PauseScreen/Retry_Button.png", "PauseScreen/Retry_Button(Click).png", CC_CALLBACK_1(PauseMenu::Retry, this)); auto mainMenuItem = MenuItemImage::create("PauseScreen/Menu_Button.png", "PauseScreen/Menu_Button(Click).png", CC_CALLBACK_1(PauseMenu::GoToMainMenuScene, ...

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