分数提交失败

时间:2011-03-11 07:51:13

标签: iphone objective-c gamekit

我在cocos2d中总是收到失败,但是当我在基于视图的应用程序中运行此项目时,它会给我成功,并且分数将很容易提交

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


GKScore *myScoreValue = [[[GKScore alloc] initWithCategory:@"123"] autorelease];
myScoreValue.value =  lastScore;

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

}];

2 个答案:

答案 0 :(得分:6)

我也有这个错误。我认为当您登录常规游戏中心并试图使用需要沙盒的应用程序进行身份验证时,就会发生这种情况。但我不确定,那只是猜测。

对我有用的是使用Game Center应用程序注销,然后再次尝试该应用程序,这将登录或创建一个沙盒用户。

不是最具描述性的错误消息。

答案 1 :(得分:0)

您是否添加了GameKit框架,以及;你在哪里放置代码?

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

}];

您必须在用户启动应用程序或调用viewDidLoad函数时进行身份验证。

我认为我真的不明白你的问题是什么。你有什么警告?