cocos2d-js,用schedule刷新时间
this.schedule是cc.Node的内置函数。
实现起来非常简单:
var GameLayer = cc.Layer.extend({
onEnter: function() {
var timelb = cc.LabelTTF.create( new Date().toLocaleString(), "宋体", 18, cc.size(180, 180), cc.TEXT_ALIGNMENT_LEFT);
timelb.x = 100;
timelb.y = 80;
timelb.color = cc.color(255, 0, 0);
this.addChild(timelb,10);
this.schedule(function(){
timelb.setString(new Date().toLocaleString());
}, 1); //1秒更新一次
}
};)