// Created by Jacedy on 14-8-11.
#include "GameScene.h"
USING_NS_CC;
cocos2d::Scene* GameScene::createScene()
{
auto scene = Scene::create(); //创建一个场景
auto layer = GameScene::create(); //创建一个图层
scene->addChild(layer);
return scene;
}
//初始化当前的图层
bool GameScene::init()
{
if (!Layer::init()) //初始化父类
return false ;
//获取屏幕大小
size = Director::getInstance()->getVisibleSize();
//auto size = Director::getInstance()->getWinSize();
//获取系统时间
struct timeval now;
struct tm * time ;
gettimeofday(&now, NULL);
time = localtime (&now.tv_sec); //microseconds: 微秒
int year = time ->tm_year +1900;
log ( "year = %d" , year); //显示年份
char date1[32] = {0};
sprintf (date1, "%d %02d %02d" , ( int ) time ->tm_year + 1900, ( int ) time ->tm_mon + 1, ( int ) time ->tm_mday);
log ( "%s" , date1); //显示年月日
char date2[50] = {0};
sprintf (date2, "%02d %02d %02d" , ( int ) time ->tm_hour, ( int ) time ->tm_min, ( int ) time ->tm_sec);
log ( "%s" , date2); //显示时分秒
//return StringUtils::format("%s", date); std::string getcurrTime(){}
return true ;
}
void GameScene::menuCallback(Ref* pSender)
{
}
|