import Tween = Laya.Tween;
import { SettingController, SoundType } from "../../GameLogic/SettingController";
export default class ImageRunTime extends Laya.Image {
    public scaleTime: number = 80;
    constructor() {
        super();
        //设置组件的中心点
        // this.anchorX = this.anchorY = 0.5;
        this.on(Laya.Event.MOUSE_DOWN, this, this.scaleSmall);
        this.on(Laya.Event.MOUSE_OVER,this,this.overs);
        this.on(Laya.Event.MOUSE_UP, this, this.scaleBig);
        this.on(Laya.Event.MOUSE_OUT, this, this.mouseout);
    }
    protected CZ: Function;
    // private bigTween: Tween;
    // private SmallTween: Tween;
    private clickId = false;
    private scaleBig(e: Laya.Event): void {
        //变大还原的缓动效果
        if (!this.clickId) return;
        this.clickId = false;
        //  this.bigTween = Tween.to(this, { scaleX: 1, scaleY: 1 }, this.scaleTime);
      //  SettingController.Instance.PlaySound(SoundType.click);
        this.alpha = 1;
        if (this.CZ) {
            this.CZ();
        }
    }
    overs(){
        this.alpha = 0.7;
    }
    private mouseout(){
        this.alpha = 1;
    }
    private scaleSmall(e: Laya.Event): void {
        // if (this.gray) return;
        //缩小至0.8的缓动效果
        this.clickId = true;
        // this.alpha = 0.7;
        //  this.SmallTween = Tween.to(this, { scaleX: 0.8, scaleY: 0.8 }, this.scaleTime);
    }
    onDestroy() {
        this.ClearRunTime();
    }
    protected ClearRunTime() {
        // if (this.bigTween) {
        //     this.bigTween.clear();
        // }
        // if (this.SmallTween) {
        //     this.SmallTween.clear();
        // }
        this.off(Laya.Event.MOUSE_DOWN, this, this.scaleSmall);
        this.off(Laya.Event.MOUSE_UP, this, this.scaleBig);
        this.off(Laya.Event.MOUSE_OUT, this, this.mouseout);
        this.off(Laya.Event.MOUSE_OVER,this,this.overs);
        this.CZ = null;
    }
}