Time for action – displaying stats when losing and winning
There are a few more dialogs that we need to add quickly. The first one is the dialog that is displayed when we win or lose the game. In this dialog, we will display the gathered statistics and again the same buttons to restart or exit the game. Otherwise, you cannot do anything when you win or lose.
Open an Xcode project and create a new
CCNode
subclass calledWinLoseDialog
. It is better to place this too in theScenes
group in order to keep things more organized.Open the
GameStats.h
file and add thetimeSpent
property; we will use it to count the time that the player spent to beat or lose the level:@property (nonatomic, assign) float timeSpent;
Open the
GameStats.m
file and initialize this property to0
inside theinit
method:self.timeSpent = 0;
Open the
GameScene.m
file and find theupdate:
method. Add the following line, right after the line where we check that the game state isGameStatePlaying
:-(void)update:(CCTime)dt { if...