Cocos2dx 显示当前日期时间
发布时间:2020-12-14 20:01:54 所属栏目:百科 来源:网络整理
导读:获取当前的时间,windows和android都适用 span id="articlecontent"/spanprestruct 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
获取当前的时间,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" class="cpp"><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()); } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |