export class UIBase extends cc.Component { enableParam: any = null; private _tweenobj = { progress: 0 }; protected _usePopUpEffect: boolean = true; protected _useCloseEffect: boolean = true; protected _closing: boolean = false; /**正在关闭特效中 */ get closing(): boolean { return this._closing; } /**弹出特效,子类可复写 */ onPopUpEffect() { if (this._usePopUpEffect) { this.node.setScale(0.1, 0.1, 1); this._tweenobj.progress = 0; cc.tween(this._tweenobj).to(0.2, { progress: 1 }, { onUpdate: this.onEffectUpdate.bind(this), easing: 'backOut' }).call(this.onPopUpEffectFinish.bind(this)).start(); } } private onEffectUpdate(target: { progress: number }, ratio: number) { this.node.setScale(target.progress, target.progress); } protected onPopUpEffectFinish() { } onBeforeClose() { cc.Tween.stopAllByTarget(this._tweenobj); } onCloseEffect(callBack: Function, callBackThisObj: any) { if (this._useCloseEffect) { this._closing = true; this._tweenobj.progress = 1; cc.tween(this._tweenobj).to(0.2, { progress: 0 }, { onUpdate: this.onEffectUpdate.bind(this), easing: 'backIn' }).call(() => { this._closing = false; callBack.call(callBackThisObj); }).start(); } else { callBack.call(callBackThisObj) } } // private onCloseEffectUpdate(target: { progress: number }, ratio: number) { // // target.setScale(ratio, ratio, 1); // this.node.setScale(target.progress, target.progress); // // log(target.progress, ratio); // } }