GameKit sends different types of points

I have an application in which there are 5 different game modes, 3 of which have an integer point, and 2 of them have an estimate of the time (how quickly they complete the game).

How to set up my reportScore: method reportScore: so that my leaderboard is set up in iTunes Connect (which displays high scores in the lowest and highest format up to a hundredth of a second), will receive my user account in time format?

I would like to send it as NSTimeInterval .

The method that Apple Docs points to accepts only an integer as an estimate:

 - (void) reportScore: (int64_t) score forCategory: (NSString*) category { GKScore *scoreReporter = [[GKScore alloc] initWithCategory:category]; scoreReporter.value = score; [scoreReporter reportScoreWithCompletionHandler:^(NSError *error) { if (error != nil) { //handle the score to submit again later } }]; } 

UPDATE

I did some research on this, and I know that you can only send ratings to Game Center game centers as int64_t . So, how do I format this integer so that my leaderboard formats it as time up to a hundredth of a second?

Thank you for your help!

+4
source share
1 answer

From the Apple documentation :

The value provided by the evaluation object is interpreted by the Game Center only when formatting for display. You determine how your points are formatted when you define the leaderboard in iTunes Connect.

ie you need to convert the time to an integer and send it. If you need 1 / 100s accuracy, you can multiply the NSTimeInterval floating point by 100 and round it to the nearest integer (for example, 1,567 s β†’ 157), then send this and select the leaderboard formatting accordingly ("Elapsed time - to the hundredth of a second" If I remember it right).

+5
source

Source: https://habr.com/ru/post/1442351/


All Articles