How can I create sound emmiters that pan and change volume based on distance from the player in a 2D game?
You can then
Or, if it's a short, one-shot sound effect, you can simply use
Here is some code that I have used in the past to set the volume and panning of a
Of course, for a 2D game, how quickly you pan and how quickly you fade out sounds as they go off screen will depend on your game. You should modify the maths to suit your own game's mood.
There is a 3D audio example on XNA's app hub. I'm pretty sure you can take the same concept for 2D.