O'Reilly logo

Learning iPhone Game Development with Cocos2D 3.0 by Kirill Muzykov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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:

  1. Create a new Objective-C class in the Common group. Name the class HighscoreManager and make it a subclass of NSObject.
  2. 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
  3. Then, open the HighscoreManager.h ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required