Time for action – using the text field
What's the purpose of the highscores table if you can't beat any of the highscores? Let's change that and replace the test data with the actual highscores. To do this, we're going to need the player to enter their name when they beat a highscore:
- Create a new Objective-C class in the
Common
group. Name the classHighscoreManager
and make it a subclass ofNSObject
. - Open the
HighscoreManager.h
file and replace its contents with the following code:#import "GameStats.h" #define kMaxHighscores 5 @interface HighscoreManager: NSObject -(NSArray *)getHighScores; -(BOOL)isHighscore:(int)score; -(void)addHighScore:(GameStats *)newHighscore; +(HighscoreManager *)sharedHighscoreManager; @end
- Then, open the
HighscoreManager.h ...
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.