获取当前时间(毫秒)Cocos2d [英] Getting current time in milliseconds Cocos2d

查看:303
本文介绍了获取当前时间(毫秒)Cocos2d的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已尝试google了,但我仍然找不到最好的答案。

I've tried to google around but I still can't find the best answer.

我想要的都很简单,我只想得到当前

All I want is very simple, I just want to get the current time in milliseconds.

推荐答案

如何在cocos2d中执行此操作? p>首先是类变量:

First, a class variable:

CGFloat gameTime;

然后在您的课程中初始化:

Then in your class initialize:

[self scheduleUpdate];

最后,虽然还在您的课程中:

Finally, while still in your class:

- (void) update:(ccTime)delta {
    gameTime += delta;
}

delta是自上次更新调用以来的毫秒数。将gameTime保存在数据库中的某个地方,用于生命周期gameTime。

delta is the milliseconds since the last call of update. Save gameTime somewhere in a database for lifetime gameTime.

这篇关于获取当前时间(毫秒)Cocos2d的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆