1

I need help with developing Game Center! I found this developer web page http://blog.lucaslouca.com/game-center-leaderboard-ios-7-app/#comment-3761 and need some help with it

Here are my questions!

Hi, my name is David! I have developed game, it is like flappy bird and I need to implement game center! I have MyScene.m and MyScene.h, so I understand steps up to 7, but don't know if I should add those three files to my game I am not experienced game developer and need some help. I have few questions: 1) Do I have to add thee three files to my own game in order for game center to work GameCenterManager.h GameCenterManager.m AppSpecificValues.h? 2) Where exactly I should put this code? " // Dummy Highscore NSUInteger _highscore = 1234;

// Sumbit highScore [_gameCenterManager reportScore: _highscore forLeaderboardID:@"1"]; "

in MyScene.m? if yes can I put it in -(id)initWithSize:(CGSize)size delegate:(id)delegate state:(GameState)state or in -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event (I have created button for game center and called the method in touches began). 3) Where should I put this delegate method - GKGameCenterControllerDelegate (Step 9) in My Scene.m or in View Controller.m? For general info: I have only one UIView Controller in my game which is view controller. the scenes are navigated by "switch" method, each scene is game state something, of example GameStateMainMenue or GameStatePlay and so on. Thank you for your help!

  • possible duplicate of [Game Center in IOS 7 leaderboard](http://stackoverflow.com/questions/24967767/game-center-in-ios-7-leaderboard) – Wyetro Oct 07 '14 at 00:30
  • Ok Wyatt! I will try to implement your version and tell you how it goes – David Muldarov Oct 07 '14 at 19:17
  • OK Wyatt, I created new objective C file name it GCHelper and added it to my file. Then I copied your GCHelper.h and GCHelper.m from Game Center in IOS 7 leaderboard – Wyatt Mufson and pasted them into my GCHelper.h and m but when I build and run player doesn't get authenticated! Do I need to do something additional like add a navigation View Controller? – David Muldarov Oct 07 '14 at 20:31
  • I authenticate in the app delegate – Wyetro Oct 07 '14 at 20:32
  • What code do you put there? – David Muldarov Oct 07 '14 at 20:47
  • Wyatt so you saying this two GCHelper.h and GChelper.m will not authenticate player? I need to put some code in app delegate in ApplicationDidFinishLaunchingWithAptions? And what code should I put there? – David Muldarov Oct 07 '14 at 21:13
  • You need to call the authenticate method from gchelper inthe app delegate – Wyetro Oct 07 '14 at 21:15
  • I called the authenticate method like this [self authenticateLocalPlayer]; in - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions but got this error " No visible interface For AppDelegate declares "authenticateLocalUser" What did i do wrong – David Muldarov Oct 07 '14 at 21:23
  • I added your [[GCHelper sharedGameKitHelper] authenticateLocalPlayer]; method to didFinishLaunchingWithOptions in app delegate but I am getting 2 errors: 1st is ARCSemantic issue "No known class method for selector 'sharedGameKitHelper' and second error is ARC Semantic Issue no known instance method for selector 'authenticateLocalPlayer' What do I fix now? – David Muldarov Oct 07 '14 at 22:24
  • You have to import GCHelper.h to app delegate... – Wyetro Oct 07 '14 at 22:25
  • This what I have in my AppDelegate.m #import "GCHelper.h" #import "AppDelegate.h" but still have those two errors – David Muldarov Oct 07 '14 at 22:32
  • And you are sure you copied in all of GCHelper.h from the other page? – Wyetro Oct 07 '14 at 22:38
  • May I suggest you guys continue this conversation at http://chat.stackoverflow.com/ – Wilbo Baggins Oct 07 '14 at 22:53
  • This is how it looks my GCHelper.h. See it in answer 2 below – David Muldarov Oct 07 '14 at 22:54

1 Answers1

1

To create the necessary code for a leaderboard see here: Game Center in IOS 7 leaderboard

To authenticate the user you need this code:

[[GCHelper sharedGameKitHelper] authenticateLocalPlayer];
Community
  • 1
  • 1
Wyetro
  • 8,439
  • 9
  • 46
  • 64