0

我需要根据 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

对不起我的英语。

谢谢。

4

1 回答 1

2

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

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

于 2013-01-22T21:25:51.380 回答