The ios game center sends time and shows in the leaderboard

in my application, I need to send time to the game center, and I need to show that Elapsed Time is the second format for the hundredth time.

00: 00: 00.00

This is the format that I want to show on the leaderboard.

In my application, I get the time in the following format

ss.SS

ss = seconds SS = hundredth of a second

i converts the value to double before sending it to the game center

double newScoreDouble = [newScore doubleValue]; 

But when I send a double account to the game center, he asks me to convert it to int64_t format. But when I convert it to this format, it loses part of the double value.

 double intPart = 0; double fractPart = modf(newScoreDouble, &intPart); int isecs = (int)intPart; int min = isecs / 60; int sec = isecs % 60; int hund = (int) (fractPart * 100); int64_t time_to_send_through_game_center = min*6000 + (sec*100 + hund); 

so I convert double to int64_t

Can anyone tell me how to send an integer double value to the game center and display it in the Elapsed time - up to the hundredth second format.

thanks

+4
source share
1 answer

I have done this before. When you record an account in the hundredth, second format. You must multiply your seconds by one hundred before sending.

So, let's say the user dialed 1 minute 44 seconds 300 milliseconds: 1:44:30 = 104.3 seconds. Then you would set the value property of the GKScore object to 104.3 * 100 = 10430 and send it that way.

Try it :)

+11
source

All Articles