获取当前的时间,windows和androID都适用 <span ID="articlecontent"></span><pre>struct tm *tm; time_t timep; time(&timep); tm = localtime(&timep); int year = tm->tm_year + 1900; int month = tm->tm_mon + 1; int day = tm->tm_mday; int hour=tm->tm_hour; int minute=tm->tm_min; int second=tm->tm_sec; auto time_str = String::CreateWithFormat("%d / %d / %d,%d : %d : %d",year,month,day,hour,minute,second);m_timeLabel = Label::createWithTTF(time_str->getCString(),"Fonts/Marker Felt.ttf",24);this->addchild(m_timeLabel,1);schedule(schedule_selector(HelloWorld::UpdateTime),5);voID HelloWorld::UpdateTime(float dt){ <pre name="code" ><pre> struct tm *tm; time_t timep; time(&timep); tm = localtime(&timep); int year = tm->tm_year + 1900; int month = tm->tm_mon + 1; int day = tm->tm_mday; int hour=tm->tm_hour; int minute=tm->tm_min; int second=tm->tm_sec; auto time_str = String::CreateWithFormat("%d / %d / %d,second);m_timeLabel->setString(time_str->getCString()); } 总结
以上是内存溢出为你收集整理的Cocos2dx 显示当前日期时间全部内容,希望文章能够帮你解决Cocos2dx 显示当前日期时间所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)