Have the listener follow a camera or a renderable, every frame.
Pass app.viewport and world-placed sounds pan and fade around the view
with nothing else to write. Pass the player and they are heard from the
character rather than the camera, which is usually what a scrolling game
with a lagging camera wants. Pass null to stop, leaving the listener
where it was.
Where the ear goes depends on the target:
a Camera2d is heard from the CENTER of its view (worldView, so its
offset and zoom count), not from its pos, which is the view's
top-left corner.
a Camera3d is heard from its pos, which is its eye, and also
contributes its ORIENTATION, so turning the camera swings the stereo
image.
any other renderable is heard from getAbsolutePosition(), position
only: its pos, which is where its anchorPoint sits. That is its
center under the (0.5, 0.5) default of a Renderable or a Sprite,
but its TOP-LEFT corner under the (0, 0) of an Entity or of any
object loaded from Tiled.
Following stops on its own if the target is destroyed, which a stage that
owns its camera does on every state change.
Have the listener follow a camera or a renderable, every frame.
Pass
app.viewportand world-placed sounds pan and fade around the view with nothing else to write. Pass the player and they are heard from the character rather than the camera, which is usually what a scrolling game with a lagging camera wants. Passnullto stop, leaving the listener where it was.Where the ear goes depends on the target:
Camera2dis heard from the CENTER of its view (worldView, so itsoffsetandzoomcount), not from itspos, which is the view's top-left corner.pos, which is its eye, and also contributes its ORIENTATION, so turning the camera swings the stereo image.getAbsolutePosition(), position only: itspos, which is where itsanchorPointsits. That is its center under the(0.5, 0.5)default of aRenderableor aSprite, but its TOP-LEFT corner under the(0, 0)of anEntityor of any object loaded from Tiled.Following stops on its own if the target is destroyed, which a stage that owns its camera does on every state change.