提交给Game Center的高分不工作

时间:2012-05-18 12:25:32

标签: iphone ipad game-center

我正在做一个基于数学的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");
        }

    }];
}

1 个答案:

答案 0 :(得分: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];

 }];
}

问候

安瑟伦