我需要根据爆炸的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
对不起我的英语。
感谢。
答案 0 :(得分:2)
pan = (PositionOfExplosion.X - 240.0f) / 240.0f
然后你可以夹到-1..1
。