ScaleDisplayAction.ts 900 Bytes

const { ccclass, property } = cc._decorator;

@ccclass
export default class ScaleDisplayAction extends cc.Component {

    @property
    speed: number = 1;
    @property
    scaleXMax: number = 1;
    @property
    scaleXMin: number = 0;
    @property
    scaleYMax: number = 1;
    @property
    scaleYMin: number = 0;

    private readonly _baseTime: number = 1;

    onLoad() { }

    start() {

    }

    onEnable() {
        this.node.scaleX = this.scaleXMin;
        this.node.scaleY = this.scaleYMin;
        let actTime: number = this._baseTime / this.speed;
        let scaleAct = cc.scaleTo(actTime, this.scaleXMax, this.scaleYMax);
        this.node.stopAllActions();
        this.node.runAction(scaleAct.easing(cc.easeSineOut()));
    }

    onDisable() {
        this.node.stopAllActions();
        this.node.scaleX = this.scaleXMin;
        this.node.scaleY = this.scaleYMin;
    }
}