Class WaterAnimalSoundPlayer

java.lang.Object
com.csse3200.game.components.audio.WaterAnimalSoundPlayer

public class WaterAnimalSoundPlayer extends Object
This class is responsible for managing the playback of water-animal-related sounds, specifically focusing on swimming sounds. It utilizes the AudioManager to handle sound volume levels.
  • Constructor Details

    • WaterAnimalSoundPlayer

      public WaterAnimalSoundPlayer(String swimmingSoundPath)
      Constructs a new WaterAnimalSoundPlayer with a specific path to the swimming sound asset.
      Parameters:
      swimmingSoundPath - Path to the swimming sound file.
  • Method Details

    • playSwimmingSound

      public void playSwimmingSound()
      Plays the swimming sound in a loop at the volume specified by the AudioManager. If the sound is already playing, this method does nothing.
    • stopSwimmingSound

      public void stopSwimmingSound()
      Stops the swimming sound if it is currently playing. Resets the identifier to ensure it can be restarted.
    • updateSwimmingSound

      public void updateSwimmingSound(boolean isSwimming)
      Updates the playing state of the swimming sound based on the animal's movement. Plays or stops the swimming sound based on whether the animal is swimming.
      Parameters:
      isSwimming - True if the animal is swimming and the sound should be played; false otherwise.