Package dev.kyzel.sfx

Class Sound

java.lang.Object
dev.kyzel.sfx.Sound

public class Sound extends Object
A class to handle Sound.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final byte[]
    The bytes of the input file.
    private final AudioFormat
    Format of the input audio file.
    static final Sound
    The sound when an Entity is hurt.
    static final Sound
    The sound when player's level goes up.
    static final Sound
    The sound when player loses.
    static final Sound
    The sound when player misses.
    static final Sound
    The sound when player is hurt.
    private Clip
    The clip that is currently playing.
    static final Sound
    The sound when player's score goes up.
    static final Sound
    The theme song of the game.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Sound(String path)
    Creates a new Sound with the given path.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Plays the sound.
    void
    play(boolean loop)
    Plays the sound.
    void
    Stops if the sound is currently playing.

    Methods inherited from class java.lang.Object

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

    • THEME

      public static final Sound THEME
      The theme song of the game.
    • SCORE_UP

      public static final Sound SCORE_UP
      The sound when player's score goes up.
    • LEVEL_UP

      public static final Sound LEVEL_UP
      The sound when player's level goes up.
    • HURT

      public static final Sound HURT
      The sound when an Entity is hurt.
    • LOSE

      public static final Sound LOSE
      The sound when player loses.
    • PLAYER_HURT

      public static final Sound PLAYER_HURT
      The sound when player is hurt.
    • MISS

      public static final Sound MISS
      The sound when player misses.
    • format

      private final AudioFormat format
      Format of the input audio file.
    • bytes

      private final byte[] bytes
      The bytes of the input file.
    • playingClip

      private Clip playingClip
      The clip that is currently playing.
  • Constructor Details

    • Sound

      public Sound(String path)
      Creates a new Sound with the given path.
      Parameters:
      path - the path of the sound file
  • Method Details

    • play

      public void play()
      Plays the sound.
    • stop

      public void stop()
      Stops if the sound is currently playing.
    • play

      public void play(boolean loop)
      Plays the sound.
      Parameters:
      loop - the sound will be looped if true, and vice versa