// Learn TypeScript: // - https://docs.cocos.com/creator/manual/en/scripting/typescript.html // Learn Attribute: // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html // Learn life-cycle callbacks: // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html const {ccclass, property} = cc._decorator; @ccclass export default class NewClass extends cc.Component { // @property(cc.Label) // label: cc.Label = null; // @property // text: string = 'hello'; num = 10; // LIFE-CYCLE CALLBACKS: onLoad () { //this.node.on("mousedown",this.move, this); this.schedule(this.coundown, 1); } coundown() { //cc使用函數:要用this //cc使用變數:也要用this //cc使用組件:要用cc(cc.Label) this.num -= 1; if(this.num==0) { this.unschedule(this.coundown); } this.node.getComponent(cc.Label).string = this.num.toString(); } start () { } // update (dt) {} }