设置立体声时更新音频路由

This commit is contained in:
unanmed 2023-06-16 19:17:45 +08:00
parent a70a17b51e
commit 1209acce50
2 changed files with 13 additions and 3 deletions

View File

@ -42,6 +42,8 @@
- 每个怪物加一个怪物说明
- 歌词展示系统
- 小地图显示框,可以选择是否显示剩余怪物数量等
- 怪物死亡特效
- 区域名称显示特效3D 粒子
### 第二章 智慧

View File

@ -11,7 +11,7 @@ export class SoundEffect extends AudioPlayer {
private _stopingAll: boolean = false;
private playMap: Map<AudioBufferSourceNode, number> = new Map();
stereo: boolean = false;
private _stereo: boolean = false;
gain: GainNode = AudioPlayer.ac.createGain();
panner: PannerNode | null = null;
@ -24,6 +24,14 @@ export class SoundEffect extends AudioPlayer {
return this.gain.gain.value;
}
set stereo(value: boolean) {
this._stereo = value;
this.initAudio(value);
}
get stereo(): boolean {
return this._stereo;
}
constructor(data: ArrayBuffer, stereo: boolean = false) {
super(data);
@ -35,10 +43,10 @@ export class SoundEffect extends AudioPlayer {
this.playMap.delete(node);
});
this.on('update', () => {
this.initAudio(this.stereo);
this.initAudio(this._stereo);
});
this.stereo = stereo;
this._stereo = stereo;
}
/**