September 2014
Beginner
266 pages
5h 38m
English
One of the best ways to ensure that the player keeps playing the game is to make him/her beat his/her own high score. Cococs2d-x has a very easy way of storing values in the game, which we will use to compare the previous high score with the current score. If the current score is higher than previous score, we will replace the old high score value with the new one.
For this, in the GameOver() function, add the following:
int highScore = CCUserDefault::sharedUserDefault()->getIntegerForKey("bazookaGameHighScore");
CCUserDefault is a singleton that stores all the user-defined defaults. But you need to provide a unique key for each of the variables that you either want to store or would like to recall.
In this case, I am retrieving ...
Read now
Unlock full access