-
Creator 版本:1.6.2
-
目标平台: Android
cc.Class({
extends: cc.Component,
properties: {
label: {
default: null,
type: cc.Label
},
// defaults, set visually when attaching this script to the Canvas
text: 'Hello, World!'
},
// use this for initialization
onLoad: function () {
this.type = 0;
var n = 0;
this.timeCb = ()=>{
if(this.type == 1){
this.label.string = ++n;//时间
}else{
this.label.string = "";
}
this.t = setTimeout(this.timeCb, 1000);
}
this.timeCb();
},
btnClick:function(event, tag){
cc.log("点击后每秒设置一次label.string");
this.type = 1;
},
// called every frame
update: function (dt) {
},
});
