Issue background
IOS Gamekit, using Gkscore to submit fractions, and its value is a int64_t official document, can we only submit a fraction of the integer type (int)? What if I have a game to submit a floating-point (float) score?
Solution Solutions
In fact, Game Center can help us do that. The document says:
The value provided by a score object was interpreted by Game Center if formatted for display. Determine how your scores is formatted when you define the leaderboard on ITunes Connect.
That is, the data that is transmitted at the time of submission will vary depending on your settings in ITunes Connect, resulting in the final display.
For example, I submit a score of 123 with Gkscore, and if it is set to a fraction format type integer (integer) in ITunes Connect, the score 123 is displayed in the leaderboard (leaderboard);
If you set the fraction format type to Fixed point-to 2 decimals, the score in the leaderboard (leaderboard) is displayed as 1.23.
Application examples
I have a small game, participate in the ranking of the data for the player's survival time, in seconds, accurate to 2 digits after the decimal point.
Then I will put the value * 100 before submission and convert it to int64_t, and set the fractional format type to point-to 2 decimals in ITunes Connect.
int64_t intBestScore = (int64_t)([DataUtil getBestScore] * 100);NSString *leaderboardId = @"grp.StoneCrashBestRecord";[[ABGameKitHelper sharedHelper] reportScore:intBestScore forLeaderboard:leaderboardId];
P.S: It is highly recommended to abgamekithelper this open source project, which is handy for integrating game Center with it.
Submit floating-point data (float) in Game Center's leaderboard