-1

I've been trying for a few days now to get Game Center leaderboard into my game but can't seem to understand how apple documentation and books explain it. Decided to now ask here so i can get specific answers to my problems. What i'm wanting is the least amount of code possible that will integrate Game Center leaderboards which will automaticaly submit your highest score. Apart from authenticateUser(don't even know how to do this right), i have no idea what other methods i need. This game is my first coding project, and as i am self teaching myself, asking here is my only real way of tackling problems. That being said, i would greatly appreciate anyone willing to show me how to implement leaderboards.

- (void) showLeaderboard
{
    GKGameCenterViewController *leaderboardController = [[GKGameCenterViewController     alloc] init];
if (leaderboardController != nil)
{
    leaderboardController.leaderboardCategory = self;
    [self presentViewController: leaderboardController animated: YES];
}

}

user3299383
  • 213
  • 5
  • 17

1 Answers1

0

I admire your gumption. My first coding project was a calculator and it kicked me around for days!

Your question is simple enough but unfortunately the answer is not. You said you are not even sure how to authenticate a user, which I take to mean you're not sure if you set up the iTunes Connect part correctly either. That part alone would fill up a page to explain in detail.

The basic steps involved with what you are trying to do are:

  1. Authenticate the local player.
  2. Configure your leaderboards in iTunes Connect.
  3. Add the relevant code to send the scores to Game Center.
  4. Add the code in your app to display the leaderboards to your player.

Having said that, I suggest you take a step back and get yourself an excellent book which, among other things, explains in detail how to add Leaderboards to your app. If you don't want to spend some of your hard earn cash, I am sure you can Google SpriteKit Leaderboards and come up with a couple of useful links but I suggest you consider getting this book http://www.raywenderlich.com/store/ios-7-and-ios-games-by-tutorials-bundle

You can also read the Apple Documentation on this subject.

About Game Center

Game Kit Framework Reference

sangony
  • 11,636
  • 4
  • 39
  • 55
  • for a authenticateLocalPlayer method i found authenticateWithCompletionHandler:^(NSError *error), and it is deprecated, what should be used instead? – user3299383 Apr 11 '14 at 01:44
  • I think this will answer your question http://stackoverflow.com/questions/14423995/authenticatewithcompletionhandler-is-deprecated-first-deprecated-in-ios-6-0 – sangony Apr 11 '14 at 01:55
  • another thing, i have a showLeaderboard method in my view controller, how can i call that method in another one of my classes? – user3299383 Apr 11 '14 at 02:32
  • First, your leaderboard method should not be in your VC. It should either be a class by itself or incorporated into your Scene. Second, calling another class' methods requires too complex of an answer to explain in a couple of lines. – sangony Apr 11 '14 at 02:56
  • I've added what my showLeaderBoard method looks like, and whether i have it in its own class or in the scene's class, i get a "No visible interface declares selector 'presentViewController:animated:", is there another file besides the ViewController that i need to import? – user3299383 Apr 11 '14 at 23:56
  • Take a look at this tutorial for leaderboards. http://www.appcoda.com/ios-game-kit-framework/ – sangony Apr 12 '14 at 00:16
  • besides that, i have now managed to authenticate myself and report score. When me game is over, your high score is submitted and i can see it when i go into Game Center in the simulator, just need that leaderboard while in game now – user3299383 Apr 12 '14 at 01:06