From ffe608a40fc0713df7f76ae68099364630e9c417 Mon Sep 17 00:00:00 2001 From: dgflash Date: Thu, 24 Oct 2024 09:23:55 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E4=BC=98=E5=8C=96oops.gui.replace?= =?UTF-8?q?=EF=BC=8C=E8=A7=84=E9=81=BFH5=E5=B9=B3=E5=8F=B0=E4=B8=8B?= =?UTF-8?q?=E7=BD=91=E7=BB=9C=E5=8A=A0=E8=BD=BD=E6=85=A2=E5=87=BA=E7=8E=B0?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E6=97=B6=E9=BB=91=E5=B1=8F=E6=95=88=E6=9E=9C?= =?UTF-8?q?=202.=20=E4=BF=AE=E5=A4=8D=E6=8C=89=E9=92=AE=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E7=94=A8=E5=9C=A8=E5=85=B3=E9=97=AD=E7=95=8C=E9=9D=A2=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E5=85=B3=E9=97=AD=E6=8C=89=E9=92=AE=E9=9F=B3=E6=95=88?= =?UTF-8?q?=E6=92=AD=E6=94=BE=E5=88=B0=E4=B8=80=E5=8D=8A=E6=97=B6=E8=A2=AB?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E8=87=AA=E5=8A=A8=E5=86=85=E5=AD=98=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E6=A8=A1=E5=9D=97=E9=87=8A=E6=94=BE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/core/gui/layer/LayerManager.ts | 11 ++++++++--- assets/libs/gui/button/ButtonSimple.ts | 22 ++++++++++----------- assets/libs/gui/button/UIButton.ts | 27 +++++++++++++------------- 3 files changed, 33 insertions(+), 27 deletions(-) diff --git a/assets/core/gui/layer/LayerManager.ts b/assets/core/gui/layer/LayerManager.ts index 979a229..3cee4a4 100644 --- a/assets/core/gui/layer/LayerManager.ts +++ b/assets/core/gui/layer/LayerManager.ts @@ -103,7 +103,7 @@ export class LayerManager { let finalW: number = 0; let finalH: number = 0; - + if (windowAspectRatio > designAspectRatio) { finalH = drs.height; finalW = finalH * ws.width / ws.height; @@ -256,8 +256,13 @@ export class LayerManager { * @param uiArgs 新打开场景参数 */ replace(removeUiId: number, openUiId: number, uiArgs: any = null) { - this.open(openUiId, uiArgs); - this.remove(removeUiId); + const callbacks: UICallbacks = { + onAdded: (node: Node, params: any) => { + this.remove(removeUiId); + } + }; + this.open(openUiId, uiArgs, callbacks); + } /** diff --git a/assets/libs/gui/button/ButtonSimple.ts b/assets/libs/gui/button/ButtonSimple.ts index 9212110..6710454 100644 --- a/assets/libs/gui/button/ButtonSimple.ts +++ b/assets/libs/gui/button/ButtonSimple.ts @@ -23,7 +23,7 @@ export default class ButtonSimple extends Component { type: AudioClip }) private effect: AudioClip = null!; - private effectIds: number[] = []; + // private effectIds: number[] = []; private touchCount = 0; private touchtEndTime = 0; @@ -57,10 +57,11 @@ export default class ButtonSimple extends Component { /** 短按触摸音效 */ protected async playEffect() { if (this.effect) { - const effectId = await oops.audio.playEffect(this.effect, resLoader.defaultBundleName, () => { - this.effectIds.remove(effectId); - }); - if (effectId > 0) this.effectIds.push(effectId); + oops.audio.playEffect(this.effect); + // const effectId = await oops.audio.playEffect(this.effect, resLoader.defaultBundleName, () => { + // this.effectIds.remove(effectId); + // }); + // if (effectId > 0) this.effectIds.push(effectId); } } @@ -68,11 +69,10 @@ export default class ButtonSimple extends Component { this.node.off(Node.EventType.TOUCH_END, this.onTouchEnd, this); this.node.off(Node.EventType.TOUCH_CANCEL, this.onTouchEnd, this); - if (this.effect) { - this.effectIds.forEach(effectId => { - console.log(effectId); - oops.audio.putEffect(effectId, this.effect); - }); - } + // if (this.effect) { + // this.effectIds.forEach(effectId => { + // oops.audio.putEffect(effectId, this.effect); + // }); + // } } } diff --git a/assets/libs/gui/button/UIButton.ts b/assets/libs/gui/button/UIButton.ts index 0e64258..197111a 100644 --- a/assets/libs/gui/button/UIButton.ts +++ b/assets/libs/gui/button/UIButton.ts @@ -27,7 +27,7 @@ export default class UIButton extends Button { type: AudioClip }) private effect: AudioClip = null!; - private effectIds: number[] = []; + // private effectIds: number[] = []; /** 触摸次数 */ private _touchCount = 0; @@ -61,19 +61,20 @@ export default class UIButton extends Button { /** 短按触摸音效 */ protected async playEffect() { if (this.effect) { - const effectId = await oops.audio.playEffect(this.effect, resLoader.defaultBundleName, () => { - this.effectIds.remove(effectId); - }); - if (effectId > 0) this.effectIds.push(effectId); + oops.audio.playEffect(this.effect); + // const effectId = await oops.audio.playEffect(this.effect, resLoader.defaultBundleName, () => { + // this.effectIds.remove(effectId); + // }); + // if (effectId > 0) this.effectIds.push(effectId); } } - onDestroy() { - if (this.effect) { - this.effectIds.forEach(effectId => { - console.log(effectId); - oops.audio.putEffect(effectId, this.effect); - }); - } - } + // onDestroy() { + // if (this.effect) { + // this.effectIds.forEach(effectId => { + // console.log(effectId); + // oops.audio.putEffect(effectId, this.effect); + // }); + // } + // } }