简体   繁体   English

Game Center排行榜得分仅在应用恢复时更新

[英]Game Center Leaderboard score only updates when app resumes

I've got a Game Center leaderboard in my game that I display using my own GUI using data retrieved from the GKLeaderboard loadScoresWithCompletionHandler method. 我的游戏中有一个Game Center排行榜,使用从GKLeaderboard loadScoresWithCompletionHandler方法检索到的数据,使用自己的GUI进行显示。

I report new scores using the GKScore reportScoresWithCompletionHandler method. 我使用GKScore reportScoresWithCompletionHandler方法报告新分数。 My issue is that when I report a new high score for the local player, when I open up my leaderboard GUI (which forces loadScoresWithCompletionHandler to be called), the player score isn't updated - it's displaying the old one he just beat. 我的问题是,当我为本地玩家报告新的高分时,当我打开排行榜GUI(强制loadScoresWithCompletionHandler )时,玩家分数不会更新-它显示的是他刚刚击败的旧分数。

But if I close(not kill) the game and then reopen it and open up the GUI again, hey-presto, the new score is shown. 但是,如果我关闭(而不是杀死)游戏,然后重新打开它并再次打开GUI,请记住,会显示新的分数。

This tells me that there must be some form of internal caching going on in GameKit that gets reset when the app resumes. 这告诉我,GameKit中必须进行某种形式的内部缓存,当应用恢复时,这些缓存会重置。 I do know that upon the app resuming, GC calls my authenticationHandler to let me know that it has re-authenticated the player so maybe something in that method wipes whatever internal cache is set? 我确实知道在应用恢复后,GC会调用我的authenticationHandler来通知我它已经对播放器进行了重新身份验证,因此该方法中的某些内容可能会擦除设置的任何内部缓存?

This is the first game I've worked on where I am displaying Game Center data using a custom UI and not the native GC view controller which I've never had this problem with. 这是我开发的第一款游戏,我在其中使用自定义UI而不是我从未遇到过的本机GC视图控制器来显示Game Center数据。 Has anyone had similar experience with this and could tell me why GKLeaderboard loadScoresWithCompletionHandler gives me old data? 有没有人有类似的经验,可以告诉我为什么GKLeaderboard loadScoresWithCompletionHandler给我旧数据?

I was having the same issue and it gave me sleepless night especially seeing no answer related to it on stackoverflow and other forums. 我遇到了同样的问题,这让我整夜无法入睡,尤其是在stackoverflow和其他论坛上没有任何与此相关的答案。 Then, i found somewhere that they were reporting new score whenever the level gets completes. 然后,我发现某个地方只要水平完成就可以报告新分数。 And I changed the button from submit leaderboard to show leaderboard, it resolved the issue. 我将按钮从“提交排行榜”更改为“显示排行榜”,它解决了该问题。 I am using GC view controller. 我正在使用GC视图控制器。 and i was only calling showleaderboard as it was a non-custom leaderboard. 我只是称呼showleaderboard,因为它是非自定义排行榜。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM