Adding high scores

Implementing high scores is a must for almost every game to make players compete with each other or to make players replay levels to improve their result. So let's modify our GameManager class to also manage score for each level.

Inside our GameManager class createLevel method, we already stored default score and time values, so now we only need methods to set and retrieve them.

First, we will create a method to set the score, which would simply take pack and level number and the user score as the parameters, and return true to indicate that the user has beat a high score or false if the user'sscore is lower than the highest score.

So, as done previously for almost each GameManager method, at first we try to load the pack and create ...

Get Gideros Mobile Game Development 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.