// 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 ScaleScripts extends cc.Component { @property(cc.Float) scaleStart: number = 1; @property(cc.Float) scaleEnd: number = 1; @property(cc.Float) time: number = 0.2; tw = null; // LIFE-CYCLE CALLBACKS: onLoad () { this.startTween(); } startTween () { if (null == this.tw){ this.tw = cc.tween(this.node) .repeatForever( cc.tween() .to(this.time, { scale: this.scaleEnd}) .to(this.time*1.5, { scale: this.scaleStart }) ) .start() } } stop(){ if (this.tw !=null){ this.tw.stop(); this.node.scale = this.scaleStart; this.tw = null; } } // update (dt) {} }