Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 2    Views: 99

mleonard
Apple Fan
Profile
Posts: 124
Reg: Nov 01, 2011
Conway,AR
1,940
06/18/13 09:52 AM (12 years ago)

Game Center Leaderboard button

Trying to figure out how to get a leaderboard button working. Using the "How To Make A Button Do Anything" http://www.buzztouch.com/forum/thread.php?tid=E466025FE320B48DAAE1BC5&currentPage=5 This is the only post I can find discussing it. http://www.buzztouch.com/forum/thread.php?tid=9B26A5C5B41307A09ACCC5B&currentPage=1 Putting this in the make a button do anything code doesn't seem to be enough. Can anyone give me some tips? GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init]; if (leaderboardController != nil) { leaderboardController.leaderboardDelegate = self; leaderboardController.timeScope = GKLeaderboardTimeScopeToday; leaderboardController.category = @"leaderboard1"; [self presentViewController: leaderboardController animated: YES completion:nil]; }
 
nadthevlad
Code is Art
Profile
Posts: 1025
Reg: Jun 07, 2012
Denver
21,850
like
06/18/13 09:29 PM (12 years ago)
Which screen/ plugin is this for. This book has a really good and easy to understand implementation of Gamecenter. http://www.amazon.com/iOS-Recipes-Problem-Solution-Hans-Eric-Gr%C3%B6nlund/dp/1430245999/ref=sr_1_1?ie=UTF8&qid=1371614277&sr=8-1&keywords=ios6+recipes This books implementation is largely what I used in the NAD Advanced quiz. In the nad quiz you will see this in viewDidLoad. _player = nil; [self authenticatePlayer]; The first line just sets your player id to nil. This is of type GKLocalPlayer. The second line just calls this function - (void)authenticatePlayer { GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer]; localPlayer.authenticateHandler = ^(UIViewController *authenticateViewController, NSError *error) { if (authenticateViewController != nil) { [self presentViewController:authenticateViewController animated:YES completion:nil]; } else if (localPlayer.isAuthenticated) { _player = localPlayer; } else { // Disable Game Center _player = nil; } }; } Set up your Show game center button in viewDidLoad. your button should will call showGameCenter similar to this. [_gameCenterButton addTarget:self action:@selector(showGameCenter) Add the showGameCenter and gameCenterViewControllerDidFinish methods add the bottom of your .m file. - (void)showGameCenter { [BT_debugger showIt:self theMessage:@"pressed show game center"]; GKGameCenterViewController *gameCenterController = [[GKGameCenterViewController alloc] init]; if (gameCenterController != nil) { gameCenterController.gameCenterDelegate = self; [self presentViewController:gameCenterController animated:YES completion:nil]; } } - (void)gameCenterViewControllerDidFinish:(GKGameCenterViewController *)gameCenterViewController { [self dismissViewControllerAnimated:YES completion:nil]; //[self showAction]; }
 
mleonard
Apple Fan
Profile
Posts: 124
Reg: Nov 01, 2011
Conway,AR
1,940
like
06/18/13 09:59 PM (12 years ago)
@nadthevlad great, thanks for the tips! Right now, I'm looking to add this in the Menu Buttons screen. I'll try it out as soon as I can. Thanks again!
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.