Time for action – restarting and exiting the game
There are still two buttons in the pause dialog that currently simply output to the console instead of actually doing something. Let's add the code for the Exit and Restart buttons. In addition, we are going to create a LoadingScene
class, which will help us to avoid memory errors and will use UIAlertView
to confirm the exit from the game.
Looks like a lot of work, so let's start:
- Open the Xcode project and create a new scene named
LoadingScene
in theScenes
group. - Then, open the
PauseDialog.m
file and import theLoadingScene.h
andMenuScene.h
headers:#import "LoadingScene.h" #import "MenuScene.h"
- Find the
btnRestartTapped:
method and replace its contents with the following code:-(void)btnRestartTapped:(id)sender ...
Get Learning iPhone Game Development with Cocos2D 3.0 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.