ScaleAction.ts 828 Bytes

const { ccclass, property } = cc._decorator;

@ccclass
export default class ScaleAction extends cc.Component {

    @property
    speed: number = 1;
    @property
    scaleMax: number = 2;
    @property
    scaleMin: number = 0;

    @property
    defalutScale: number = 1;

    private readonly _baseTime: number = 1;

    onLoad() { }

    start() {

    }

    onEnable() {
        this.node.scale = this.defalutScale;
        let actTime: number = this._baseTime / this.speed;
        let maxAct = cc.scaleTo(actTime, this.scaleMax);
        let minAct = cc.scaleTo(actTime, this.scaleMin);
        this.node.stopAllActions();
        this.node.runAction(cc.repeatForever(cc.sequence(maxAct, minAct)));
    }

    onDisable() {
        this.node.stopAllActions();
        this.node.scale = 1;
    }



    update(dt) { }
}