gpt4 book ai didi

iPhone gamecenter 提交最高分?

转载 作者:太空狗 更新时间:2023-10-30 03:38:18 25 4
gpt4 key购买 nike

我正在使用以下函数将分数提交到游戏中心。如何修改下面的代码,以便只有当分数高于已提交的分数时我才能发送分数?而且我不想在本地维护分数。有帮助吗?

- (void) reportScore: (int64_t) score forCategory: (NSString*) category 
{
GKScore *scoreReporter = [[[GKScore alloc] initWithCategory:category] autorelease];
scoreReporter.value = score;
[scoreReporter reportScoreWithCompletionHandler: ^(NSError *error)
{
[self callDelegateOnMainThread: @selector(scoreReported:) withArg: NULL error: error];
}];
}

谢谢。

编辑:我刚刚发现它仅由游戏中心处理...只有最高分会显示在游戏中心应用程序上。

最佳答案

您可以使用

检索以前的分数
GKLeaderboard *query = [[GKLeaderBoard alloc] initWithPlayerIDs:[NSArray arrayWithObject:yourPlayerId]];

if (query != nil)

{

[query loadScoresWithCompletionHandler: ^(NSArray *scores, NSError *error) {

if (error != nil)

// handle the error.

if (scores != nil)

// process the score information.

}];

}

获取有关 Apple GameKit Programming Guide 的更多信息

关于iPhone gamecenter 提交最高分?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3872612/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com