我有将我的分数提交到游戏中心的代码,但是每当我在游戏中心提交分数时,它说我的分数是 0。我不确定这是怎么发生的?我还导入了 GameKit 框架。
-(IBAction)submitScore{
if (highscore>0) {
GKScore *scoreReporter = [[[GKScore alloc] initWithCategory:@"MyLeaderBoardID"] autorelease];
scoreReporter.value = [[NSNumber numberWithInt:highscore] longLongValue];
NSLog(@"posted");
NSLog(@"%i",highscore);
[scoreReporter reportScoreWithCompletionHandler:^(NSError *error) {
if (error != nil) {
NSLog(@"failed!!!");
NSLog(@"%i",highscore);
} else {
NSLog(@"Succeded");
}
}];
}
我也有用于登录的代码:
[[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error) {
if (error == nil) {
NSLog(@"authintication success");
} else {
NSLog(@"authintication failed");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Game Center Disabled"
message:@"For Game Center make sure you have an account and you have a proper device connection."
delegate:self
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alert show];
}
}];
self.currentLeaderBoard = @"MyLeaderBoardID";