import Tween = Laya.Tween;
import { SettingController, SoundType } from "../../Game/SettingController";
export default class ImageRunTime extends Laya.Image {
    public scaleTime: number = 80;
    constructor() {
        super();
        //设置组件的中心点
        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 clickId = false;
    private scaleBig(e: Laya.Event): void {
        //变大还原的缓动效果
        if (!this.clickId) return;
        this.clickId = false;
        this.alpha = 1;
        if (this.CZ) {
            this.CZ();
        }
    }
    overs(){
        this.alpha = 0.7;
    }
    private mouseout(){
        this.alpha = 1;
    }
    private scaleSmall(e: Laya.Event): void {
        this.clickId = true;
    }
    onDestroy() {
        this.ClearRunTime();
    }
    protected ClearRunTime() {
        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;
    }
}