Class SFXManager

java.lang.Object
util.SFXManager

public class SFXManager extends Object
Manages sound effects (SFX) in the game.

Allows loading, playing, stopping, and adjusting volume of sound effects.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static double
    Global volume for all sound effects (0.0 to 1.0).
    private static final Map<String, javafx.scene.media.AudioClip>
    Stores loaded sound effects by name.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    load(String name, String path)
    Loads a sound effect from the given path and associates it with a name.
    static void
    play(String name)
    Plays a loaded sound effect by name.
    static void
    setVolume(double volume)
    Sets the global volume for all sound effects.
    static void
    stop(String name)
    Stops a sound effect by name if it is playing.
    static void
    Stops all currently playing sound effects.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • sounds

      private static final Map<String, javafx.scene.media.AudioClip> sounds
      Stores loaded sound effects by name.
    • globalVolume

      private static double globalVolume
      Global volume for all sound effects (0.0 to 1.0).
  • Constructor Details

    • SFXManager

      public SFXManager()
  • Method Details

    • load

      public static void load(String name, String path)
      Loads a sound effect from the given path and associates it with a name.
      Parameters:
      name - name to reference the sound effect
      path - path to the sound resource
    • play

      public static void play(String name)
      Plays a loaded sound effect by name.
      Parameters:
      name - the name of the sound effect
    • setVolume

      public static void setVolume(double volume)
      Sets the global volume for all sound effects.
      Parameters:
      volume - volume between 0.0 (mute) and 1.0 (max)
    • stop

      public static void stop(String name)
      Stops a sound effect by name if it is playing.
      Parameters:
      name - the name of the sound effect
    • stopAll

      public static void stopAll()
      Stops all currently playing sound effects.