我制作了一个辅助单例类来实现Game Center。然后我调用方法来验证我的AppDelegate中的播放器。
如果我启动应用程序,一切都好!
下一步:我想报告我的分数。我有这个方法作为报告得分
+ (void) reportScore: (Float64) score forIdentifier: (NSString*) identifier
{
GKScore* highScore = [[GKScore alloc] initWithLeaderboardIdentifier:identifier];
highScore.value = score;
[GKScore reportScores:@[highScore] withCompletionHandler:^(NSError *error) {
if (error) {
NSLog(@"Error in reporting scores: %@", error);
}
}];
}
我调用它时,我有GameOver和切换到GameOverScene前不久:
[GCTurnBasedMatchHelperr reportScore:self.scoring forIdentifier:@"score"];
我正在玩沙盒测试用户。如果我进入game center,然后进入我的游戏排行榜,它会显示:No Scores。
之后,我想以某种方式显示排行榜和分数。
如果你需要更多的代码,到这个github: https://gist.github.com/anonymous/1881303471cb9790af0b
有谁能帮我吗?好吧,我犯了一个非常简单的错误,我只是在报告分数时使用了错误的标识符。