3

我正在做一个基于数学的ios应用程序..我已经完成了将高分上传到游戏中心的代码..但这不起作用..它总是显示0作为高分..这是我的代码...

[[GKLocalPlayer localPlayer]authenticateWithCompletionHandler:^(NSError *error)
      {
            if (error ==nil) 
            {
                 CCLOG(@"Success");
            } else 
            {
                 CCLOG(@"Fail");
            }
       }];

.
.
.
.
.

-(void)showLeaderboard
{   
    if( ! gameCenterViewController_ )
        gameCenterViewController_ = [[GameCenterViewController alloc] init];

    [gameCenterViewController_ showLeaderboard];
}



-(void)submitMyScore1:(int)score1
{
    CCLOG(@"submitMyScore1--%d",score1);
    //This is the same category id you set in your itunes connect GameCenter LeaderBoard
    GKScore *myScoreValue = [[[GKScore alloc] initWithCategory:@"bigwizlist"] autorelease]; 
    myScoreValue.value = score1;

    [myScoreValue reportScoreWithCompletionHandler:^(NSError *error){
        if(error != nil)
        {
            CCLOG(@"Score Submission Failed");
        } else
        {
            CCLOG(@"Score Submitted");
        }

    }];
}
4

1 回答 1

3

我认为您需要为您的方法使用int64_t!我使用这种方法,它工作得很好:-)

-(void)submitScore:(int64_t)score category:(NSString*)category{

GKScore *gkScore = [[[GKScore alloc]initWithCategory:category]autorelease];
gkScore.value = score;

[gkScore reportScoreWithCompletionHandler:^(NSError* error)
 {
     [self setLastError:error];
     bool sucess = (error == nil);
     [delegate onScoresSubmitted:sucess];

 }];
}

问候

安瑟伦

于 2012-05-22T19:37:38.073 回答