2014-03-04 104 views
0

遊戲開啓後,它已註冊到Sandbox,但無法在GameCenter App上看到註冊數據的蹤跡。積分未被GameCenter註冊

遊戲在AppStore尚未推出,但我可以在GameCenter App上看到遊戲。

該過程很簡單。我已經設置了一個GameKitHelper,看起來它是正確的。

請看看:

GameKitHelper.h

// Include the GameKit framework 
#import <GameKit/GameKit.h> 

// Protocol to notify external 
// objects when Game Center events occur or 
// when Game Center async tasks are completed 
@protocol GameKitHelperProtocol<NSObject> 

-(void) onScoresSubmitted:(bool)success; 

@end 


@interface GameKitHelper : NSObject 

@property (nonatomic, assign) 
id<GameKitHelperProtocol> delegate; 

// This property holds the last known error 
// that occured while using the Game Center API's 
@property (nonatomic, readonly) NSError* lastError; 

+ (id) sharedGameKitHelper; 

// Player authentication, info 
-(void) authenticateLocalPlayer; 

// Scores 
-(void) submitScore:(int64_t)score 
      category:(NSString*)category; 

@end 

GameKitHelper.m

#import "GameKitHelper.h" 

@interface GameKitHelper() 
<GKGameCenterControllerDelegate> { 
    BOOL _gameCenterFeaturesEnabled; 
} 
@end 

@implementation GameKitHelper 

-(void) submitScore:(int64_t)score 
      category:(NSString*)category { 
    //1: Check if Game Center 
    // features are enabled 
    if (!_gameCenterFeaturesEnabled) { 
     CCLOG(@"Player not authenticated"); 
     return; 
    } 

    //2: Create a GKScore object 
    GKScore* gkScore = 
    [[GKScore alloc] 
    initWithCategory:category]; 

    //3: Set the score value 
    gkScore.value = score; 

    //4: Send the score to Game Center 
    [gkScore reportScoreWithCompletionHandler: 
    ^(NSError* error) { 

     [self setLastError:error]; 

     BOOL success = (error == nil); 

     if ([_delegate 
       respondsToSelector: 
       @selector(onScoresSubmitted:)]) { 

      [_delegate onScoresSubmitted:success]; 
     } 
    }]; 
} 

#pragma mark Singleton stuff 

+(id) sharedGameKitHelper { 
    static GameKitHelper *sharedGameKitHelper; 
    static dispatch_once_t onceToken; 
    dispatch_once(&onceToken, ^{ 
     sharedGameKitHelper = 
     [[GameKitHelper alloc] init]; 
    }); 
    return sharedGameKitHelper; 
} 

#pragma mark Player Authentication 

-(void) authenticateLocalPlayer { 

    GKLocalPlayer* localPlayer = 
    [GKLocalPlayer localPlayer]; 

    localPlayer.authenticateHandler = 
    ^(UIViewController *viewController, 
     NSError *error) { 

     [self setLastError:error]; 

     if ([CCDirector sharedDirector].isPaused) 
      [[CCDirector sharedDirector] resume]; 

     if (localPlayer.authenticated) { 
      _gameCenterFeaturesEnabled = YES; 
     } else if(viewController) { 
      [[CCDirector sharedDirector] pause]; 
      [self presentViewController:viewController]; 
     } else { 
      _gameCenterFeaturesEnabled = NO; 
     } 
    }; 
} 

#pragma mark Property setters 

-(void) setLastError:(NSError*)error { 
    _lastError = [error copy]; 
    if (_lastError) { 
     NSLog(@"GameKitHelper ERROR: %@", [[_lastError userInfo] 
              description]); 
    } 
} 

#pragma mark UIViewController stuff 

-(UIViewController*) getRootViewController { 
    return [UIApplication 
      sharedApplication].keyWindow.rootViewController; 
} 

-(void)presentViewController:(UIViewController*)vc { 
    UIViewController* rootVC = [self getRootViewController]; 
    [rootVC presentViewController:vc animated:YES 
         completion:nil]; 
} 
@end 

所有我要求球員的身份驗證下面的方法首先:

[[GameKitHelper sharedGameKitHelper] 
     authenticateLocalPlayer]; 

然後,當電平完成呼叫該第二方法:

[[GameKitHelper sharedGameKitHelper] 
      submitScore:(int64_t)numberMoves 
      category:kMovesLevel1LeaderboardCategory]; 

排行榜ID等於iTunesConnect。這段代碼是從http://www.raywenderlich.com/23189/whats-new-with-game-center-in-ios-6得到的,這是6.0的目標。但到目前爲止,我沒有看到任何大問題。

我錯過了什麼? 謝謝!

+0

是的,我已經等了超過24小時。有任何想法嗎?謝謝! – RickON

回答

0

您是否記得啓用iTunes Connect中的排行榜?

對於有問題的應用程序:

  1. 點擊查看詳情 - >滾動到下 - >點擊遊戲中心交換機(切換禁用之間/啓用)。
  2. 添加您要使用的排行榜。