import { _decorator, CCFloat, CCInteger, Component, tween, v3} from 'cc'; const { ccclass, property } = _decorator; @ccclass('ScaleScripts') export default class ScaleScripts extends Component { @property({ type: CCFloat }) scaleStart: number = 1; @property({ type: CCFloat }) scaleEnd: number = 1; @property({ type: CCFloat }) time: number = 0.2; tw = null; // LIFE-CYCLE CALLBACKS: onLoad () { this.startTween(); } public startTween () { if (null == this.tw){ this.tw = tween(this.node) .repeatForever( tween() .to(this.time, { scale: v3(this.scaleEnd, this.scaleEnd, this.scaleEnd)}) .to(this.time*1.5, { scale: v3(this.scaleStart, this.scaleStart, this.scaleStart) }) ) .start() } } stopAnim(){ if (this.tw !=null){ this.tw.stop(); this.node.scale = v3(this.scaleStart, this.scaleStart, this.scaleStart); this.tw = null; } } // update (dt) {} }