melonJS
    Preparing search index...

    Function setListener

    • 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.

      A Camera3d also contributes its ORIENTATION, so turning the camera swings the stereo image. Anything else contributes position only.

      Following stops on its own if the target is destroyed, which a stage that owns its camera does on every state change.

      Parameters

      • target: Renderable | null

        what to follow, or null to stop following

      Returns void

      audio.setListener(app.viewport); // hear from the camera
      audio.setListener(player); // hear from the player
      audio.setListener(null); // stop following