修复音效缓存中的数据不会被命中的问题

This commit is contained in:
dgflash
2024-09-03 22:56:31 +08:00
parent 7482f61d6c
commit 3927f54436

View File

@@ -57,15 +57,15 @@ export class AudioEffect extends AudioSource {
callback && callback();
}
else {
const key = `${bundleName}:${url}`;
// 地址加载音乐资源后播放
if (this.effects.has(url) == false) {
if (this.effects.has(key) == false) {
oops.res.load(bundleName, url, AudioClip, (err: Error | null, data: AudioClip) => {
if (err) {
error(err);
return;
}
let key = `${bundleName}:${url}`;
this.effects.set(key, { source: false, bundle: bundleName, path: url, ac: data });
this.playOneShot(data, this.volume);
callback && callback();
@@ -73,7 +73,7 @@ export class AudioEffect extends AudioSource {
}
// 播放缓存中音效
else {
const rr = this.effects.get(url)!;
const rr = this.effects.get(key)!;
this.playOneShot(rr.ac, this.volume);
callback && callback();
}