From fc3a150be1dd5a9a8be9d408b963c303c960c0ec Mon Sep 17 00:00:00 2001 From: dgflash Date: Tue, 23 Sep 2025 22:32:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DGameComponent.playEffect?= =?UTF-8?q?=E6=92=AD=E6=94=BE=E9=9F=B3=E6=95=88=E6=9C=AA=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E4=BC=A0=E5=8F=82=E6=95=B0=E6=97=B6=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/module/common/GameComponent.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/assets/module/common/GameComponent.ts b/assets/module/common/GameComponent.ts index 031ce00..8ed4677 100644 --- a/assets/module/common/GameComponent.ts +++ b/assets/module/common/GameComponent.ts @@ -340,10 +340,20 @@ export class GameComponent extends Component { async playEffect(url: string, params?: IAudioParams): Promise { return new Promise(async (resolve, reject) => { // 音效播放完,关闭正在播放状态的音乐效果 - if (params == null) params = {}; + if (params == null) { + params = { bundle: resLoader.defaultBundleName }; + } + else if (params.bundle == null) { + params.bundle = resLoader.defaultBundleName; + } let ae = await oops.audio.playEffect(url, params); - this.addPathToRecord(ResType.Load, ae.params!.bundle!, url); - resolve(ae); + if (ae) { + this.addPathToRecord(ResType.Load, ae.params!.bundle!, url); + resolve(ae); + } + else { + resolve(null!); + } }); } //#endregion