问题
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!
回答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];
来源:https://stackoverflow.com/questions/26226830/implement-a-game-center-leaderboard-ios-7