calcVolumeFactor 计算衰减后的音量系数
calcVolumeFactor
类型: MethodDeclaration
所属类: MultipleAudioPlayer
定义位置: audio.ts
描述
计算衰减后的音量系数
参数 position: 音效位置
参数 range: 音量衰减范围
返回值:音量系数
参数
| 参数名 | 类型 | 描述 | 默认值 | 
|---|---|---|---|
| position | Point | - | - | 
| range | number | - | - | 
返回值
类型: number
音量系数
源代码
位置: 第 466 行
public calcVolumeFactor(position: Point, range: number): number {
    const dist = Math.dist(Camera.x, Camera.y, position.x, position.y)
    const easing = Easing.get(AudioManager.attenEasingId)
    const attenuation = easing.get(dist / range)
    return 1 - attenuation
  }
文档生成时间:2025/7/21 20:53:39