在CCTime中,存在接口gettimeofdayCocos2d:
class CC_DLL CCTime { public: static int gettimeofdayCocos2d(struct cc_timeval *tp,void *tzp); static double timersubCocos2d(struct cc_timeval *start,struct cc_timeval *end); };@H_502_4@ 我们调用接口获取时间,但是这个时间只有秒和微妙,就需要我们自己进行装换了:
int getCurrentTime() { struct cc_timeval now; CCTime::gettimeofdayCocos2d(&now,NULL); return now.tv_sec * 1000 + now.tv_usec / 1000; }原文链接:https://www.f2er.com/cocos2dx/341926.html