iphone - ios 游戏中心提交时间并在排行榜中显示

标签 iphone ios datetime double game-center

在我的应用程序中,我需要将时间提交给游戏中心,并且我需要以“已用时间 - 百分之一秒”格式显示。

00:00:00.00

这是我想在排行榜中显示的格式。

在我的应用程序中,我按以下格式获取时间

ss.SS

ss = 秒 SS = 百分之一秒

我在将它发送到游戏中心之前将值转换为两倍

double newScoreDouble = [newScore doubleValue];

但是当我将双倍分数发送到游戏中心时,它要求我将其转换为 int64_t 格式。但是当我将它转换为那种格式时,它会丢失部分 double 值。

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);

这是我将 double 转换为 int64_t 的方式

谁能说出如何将整个 double 值发送到游戏中心并以“已用时间 - 到百分之一秒”的格式显示它。

谢谢

最佳答案

我以前做过。当您以百分之一秒格式录制乐谱时。在提交之前,您会将秒数乘以一百。

假设用户的得分为 1 分 44 秒 300 毫秒:1:44:30 = 104.3 秒。然后,您可以将 GKScore 对象的 value 属性设置为等于 104.3 * 100 = 10430 ,然后这样提交。

试一试:)

关于iphone - ios 游戏中心提交时间并在排行榜中显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11840484/

相关文章:

iphone - iPhone 中的 OpenCV 和 iOS

iphone - 设置状态栏方向 : how to change the device orientation

ios - Swift:从其他 Viewcontroller 调用 PageViewController 中的函数

python - 分组并填充缺失的日期时间值

.net - 我如何从 Stopwatch.GetTimestamp() 到 DateTime?

ios - 快速切换 View Controller

iphone - iOS 4.3、5.0 和 6.0 中仅纵向应用程序中纵向 UIWebView 的横向全屏 youtube 电影

ios - iOS 支持哪些压缩纹理格式?

ios - 有条件地在静态单元格表​​ View 中显示单元格

R:如何根据时间和日期查找计数