Game center integration problem

Discussion in 'Public Game Developers Forum' started by Sirke, Jan 25, 2011.

  1. Sirke

    Sirke Member

    Jul 14, 2010
    7
    0
    0
    #1 Sirke, Jan 25, 2011
    Last edited: Jan 25, 2011
    Hi guys,

    I'm trying to implement Game Center in my game but met a little problem.
    I made a game center menu in my game with 2 buttons for the leader board and achievements. I'm trying to open the respective game center tabs when you hit those buttons the same way Openfeint does it but haven't been successful so far.
    I can load the tabs but always get redirected to a debug menu when trying to leave the tabs and go back to my menu.

    Did anyone encountered the same problem?
    Or someone has the time to give me a link with a step by step procedure?

    Thanks a lot.
     
  2. crazygambit

    crazygambit Well-Known Member

    Nov 15, 2010
    274
    0
    0
    Wasn't there an open source Game Center implementation of like a pong game in this very forum? I'd start with that.
     
  3. thewiirocks

    thewiirocks Well-Known Member

    Aug 28, 2009
    618
    0
    0
    Expert Software Engineer
    I am looking deep... deep into my crystal ball... deeeeepppp....

    I see in my mind's eye that you forgot to implement the Delegate Selectors... You'll need these in your class:

    Code:
    - (void)leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController
    {
        [self dismissModalViewControllerAnimated: YES];
        [viewController release];
    }
    
    - (void)achievementViewControllerDidFinish:(GKAchievementViewController *)viewController;
    {
        [self dismissModalViewControllerAnimated: YES];
        [viewController release];
    }
    You'll need to implement the delegate interfaces in the header for the class:

    Code:
    @interface MyClass : GKLeaderboardViewControllerDelegate, GKAchievementViewControllerDelegate>
    Then you'll need to make sure you set the delegate class when you launch the UIs:

    Code:
       GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init];
        if (leaderboardController != NULL) 
        {
            leaderboardController.category = self.currentLeaderBoard;
            leaderboardController.timeScope = GKLeaderboardTimeScopeAllTime;
            leaderboardController.leaderboardDelegate = self; // MAKE SURE YOU HAVE THIS!
            [self presentModalViewController: leaderboardController animated: YES];
        }
    My spherical hunk of glass seems to think that will fix you up. ;)
     
  4. Sirke

    Sirke Member

    Jul 14, 2010
    7
    0
    0
    Thanks to you both for the answers! I will check right away.
    My programming skills have been buried for almost a decade so please excuse my poor soul :)

    @thewiirocks: I surely need one of those crystal ball myself. It would make my life a lot easier and not only for the code part :D
     
  5. thewiirocks

    thewiirocks Well-Known Member

    Aug 28, 2009
    618
    0
    0
    Expert Software Engineer
    You're absolutely right. My bowling scores have never been better!
     
  6. vklymenko

    vklymenko Well-Known Member

    Jun 23, 2010
    331
    0
    0
    Lead programmer/Producer
    Europe
    hi, can you help me with my integrations : )

    - I tried to have GameCenter.mm and GameCenter.h with all functions and delegate - but how to call functions from other .m files? for example I have main app delegate class and function on_app_did_finish_load and need to call a function like ShowLeaderboard etc from here?

    - is that possible to have all GC functions in main app delegate instead separate GameCenter.mm and GameCenter.h files ? but then I have "self is undeclared" issues and can't close leaderboard view and assign delegate

    plz help me, it will be paid help:
    http://www.stonetrip.com/developer/forum/viewtopic.php?f=30&t=22335&p=29700#p29700
     

Share This Page