XNA声音平移取决于X坐标

时间:2013-01-22 21:22:21

标签: xna

我需要根据爆炸的X坐标进行声音平移。

Vector2 PositionOfExplosion = ExplosionCoord;
myScreenWidth = 480; //Windows phone
float SoundPan = ??? //Mus be something like MathHelper.Clamp(???, -1, 1);
_explosion1.Play(myVolumen, myPitch, SoundPan); // Pan from -1.0 left to 1.0 right. 0 is center

恢复,

如果爆炸在

  X=0 Pan= -1 
  ...
  X=120 Pan= -0.5 
  ...
  X=240 Pan= 0 
  ...
  x=360 Pan = 0.5
  ...
  x=480 Pan= 1

对不起我的英语。

感谢。

1 个答案:

答案 0 :(得分:2)

pan = (PositionOfExplosion.X - 240.0f) / 240.0f

然后你可以夹到-1..1