Files
beimi/client/version/chess/assets/resources/script/components/BeiMiTimer.js
2017-12-21 23:04:13 +08:00

49 lines
1.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
var beiMiCommon = require("BeiMiCommon");
cc.Class({
extends: beiMiCommon,
properties: {
// foo: {
// default: null, // The default value will be used only when the component attaching
// to a node for the first time
// url: cc.Texture2D, // optional, default is typeof default
// serializable: true, // optional, default is true
// visible: true, // optional, default is true
// displayName: 'Foo', // optional
// readonly: false, // optional, default is false
// },
// ...
text: {
default: null,
type: cc.Label
}
},
// use this for initialization
onLoad: function () {
},
init:function(text , time , target){
let self = this ;
this.remaining = time ;
this.text.string = text +""+ this.remaining +"" ;
this.schedule(function() {
this.remaining = this.remaining - 1 ;
if(this.remaining < 0){
self.unschedule(this);
}else{
self.text.string = text +""+ this.remaining +"" ;
}
}, 1 , time);
},
stop:function(target){
this.remaining = 0 ;
target.destroy();
}
// called every frame, uncomment this function to activate update callback
// update: function (dt) {
// },
});