Submit floating-point data (float) in Game Center's leaderboard

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.