playAt 播放音频文件(距离衰减)
playAt
类型: MethodDeclaration
所属类: MultipleAudioPlayer
定义位置: audio.ts
描述
播放音频文件(距离衰减)
参数 guid
: 音频文件ID
参数 position
: 声音在场景中的位置
参数 volume
: 播放音量[0-1]
参数 playbackRate
: 播放速度
参数
参数名 | 类型 | 描述 | 默认值 |
---|---|---|---|
guid | string | - | - |
position | Point | - | - |
volume | number | - | n1 |
playbackRate | number | - | n1 |
返回值
类型: HTMLAudioPlayer2 \| undefined
源代码
位置: 第 447 行
public playAt(guid: string, position: Point, volume: number = 1, playbackRate: number = 1): HTMLAudioPlayer2 | undefined {
if (Math.dist(Camera.x, Camera.y, position.x, position.y) < AudioManager.attenDist) {
const audio = this.play(guid, volume, playbackRate)
if (audio) {
audio.update = () => {
audio.volume = volume * this.calcVolumeFactor(position, AudioManager.attenDist)
}
audio.update(0)
return audio
}
}
}
文档生成时间:2025/7/7 12:07:06