Advertisement
Guest User

Untitled

a guest
Apr 20th, 2014
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. -(void)authenticateLocalPlayer{
  2. GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
  3.  
  4. localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error){
  5. if (viewController != nil) {
  6. [[CCDirector sharedDirector] presentViewController:viewController animated:YES completion:nil];
  7.  
  8. }
  9. else{
  10. if ([GKLocalPlayer localPlayer].authenticated) {
  11. _gameCenterEnabled = YES;
  12.  
  13.  
  14. // Get the default leaderboard identifier.
  15. [[GKLocalPlayer localPlayer] loadDefaultLeaderboardIdentifierWithCompletionHandler:^(NSString *leaderboardIdentifier, NSError *error) {
  16.  
  17. if (error != nil) {
  18. NSLog(@"%@", [error localizedDescription]);
  19. }
  20. else{
  21. _leaderboardIdentifier = leaderboardIdentifier;
  22. }
  23. }];
  24. }
  25.  
  26. else{
  27. _gameCenterEnabled = NO;
  28. }
  29. }
  30. };
  31. }
  32.  
  33. -(void)reportScore{
  34. GKScore *score = [[GKScore alloc] initWithLeaderboardIdentifier:_leaderboardIdentifier];
  35. score.value = _points;
  36.  
  37. CCLOG(@"Score: %i ",_points);
  38.  
  39. [GKScore reportScores:@[score] withCompletionHandler:^(NSError *error) {
  40. if (error != nil) {
  41. NSLog(@"%@", [error localizedDescription]);
  42. }
  43. }];
  44.  
  45. }
  46.  
  47. - (void)restart {
  48. CCScene *scene = [CCBReader loadAsScene:@"MainScene"];
  49. [[CCDirector sharedDirector] replaceScene:scene];
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement