cocos2dx 获取系统时间

很简单的方法:

long Player::getCurrentTime()
{
	struct   tm  * tm ;  
	time_t  timep;  
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)   
	time(&timep);  
#else   
	struct  cc_timeval now;   
	CCTime::gettimeofdayCocos2d(&now, NULL);   
	timep = now.tv_sec;  
#endif 
	 tm  = localtime(&timep);  
	 long timeSecond = tm->tm_sec + tm->tm_min * 60 + tm->tm_hour * 3600;
	 return timeSecond;
}


你可能感兴趣的:(cocos2dx学习之路)