Cocos2d-X与游戏开发cocos2d-xcocos2d

cocos2d-x lua日期获取

2017-11-20  本文已影响5人  亮亮同学

cocos2d-x技术群新群:117871561
c++技术交流群:593010226

-- txt_time_ymd日期(Text)  txt_time_hms 时间 (Text) ViewLayer 显示层对象 
function MyCache.setDate(txt_time_ymd,txt_time_hms,ViewLayer)
    local timerNode = cc.Node:create()
    :addTo(ViewLayer)
  txt_time_ymd:setString(os.date("%Y-%m-%d",os.time()))
  txt_time_hms:setString(os.date("%H-%M-%S",os.time()))
  timerNode:runAction(cc.RepeatForever:create( 
                        cc.Sequence:create(
                        cc.DelayTime:create(1),
                        cc.CallFunc:create(function()
                          txt_time_hms:setString(os.date("%H-%M-%S",os.time())) 
                      end)
                  )))
end

上一篇下一篇

猜你喜欢

热点阅读