cocos2d-x之闹钟篇
来源:互联网 发布:淘宝制作宝贝详情步骤 编辑:程序博客网 时间:2024/06/16 19:00
这几天不忙,终于可以学习了 写了个闹钟 跟大家分享下
struct cc_timeval now;
CCTime::gettimeofdayCocos2d(&now, NULL);
struct tm * tm;
tm = localtime(&now.tv_sec);
nHour = tm->tm_hour;
nMinute = tm->tm_min;
nSecond = tm->tm_sec;
CCLog("时%d 分%d 秒%d",nHour,nMinute,nSecond);
CCLog("日%d 月%d 年%d",tm->tm_mday,tm->tm_mon+1,tm->tm_year +1900);
CCLog("星期%d 本年的第%d天 是否开夏令时%d",tm->tm_wday,tm->tm_yday+1,tm->tm_isdst);
CCLog("%ld 当前时区的名字%s",tm->tm_gmtoff,tm->tm_zone);
this->schedule(schedule_selector(HelloWorld::timeUpdate), 1);
void HelloWorld::timeUpdate(){
CCSprite * miaozhen = (CCSprite *)getChildByTag(miaozhen_tag);
CCSprite * shizhen = (CCSprite *)getChildByTag(shizhen_tag);
CCSprite * fenzhen = (CCSprite *)getChildByTag(fenzhen_tag);
nSecond++;
if (nSecond==60) {
nSecond = 0;
nMinute++;
if (nMinute == 60) {
nMinute = 0;
nHour++;
if (nHour== 24) {
nHour = 0;
}
}
}
int ss = nHour;
if (ss>=12) {
ss = nHour - 12;
}
shizhen->setRotation(CC_RADIANS_TO_DEGREES(ss*1.0/12*2*3.14)-90);
fenzhen->setRotation(CC_RADIANS_TO_DEGREES((nMinute+1)*1.0/60*2*3.14)- 15);
miaozhen->setRotation(CC_RADIANS_TO_DEGREES((nSecond+1)*1.0/60*2*3.14)- 15);
CCLog("%d -- %d -- %d",nHour,nMinute,nSecond);
}
效果图"
- cocos2d-x之闹钟篇
- Cocos2D-x之搭建篇
- cocos2d-x网游之java服务器篇
- cocos2d-X之CCUserDefault
- Cocos2d-x之CCSpriteFrameCache
- Cocos2d-x 之CCAction
- Cocos2d-x 之CCTableView
- cocos2d-x之ActionRepeatForever
- cocos2d-x之CCAction
- cocos2d-x之helloworld
- Cocos2d-x之MenuItem
- cocos2d-x 之 XML
- cocos2d-x之导演
- cocos2d-x之场景
- cocos2d-x之精灵
- Cocos2d-x之 CCObject
- Cocos2d-x之 代理
- Cocos2d-x之JniHelper
- Android getWindow().setFlags方法
- CATransaction
- 使用MFC类库实现回声程序
- Tstringlist 应用
- uva 10626
- cocos2d-x之闹钟篇
- Android浏览器直接打开网页上的文档
- notifyDataSetChanged() 动态更新ListView
- LINUX路由表
- Delphi : record 记录类型 - 结构指针
- 关于总线事件与内存事件(RFO)
- 2013年的书单 - 技术方面
- MFC应用程序中处理消息的顺序
- 较合适的背景颜色设置