Class SoundManager

java.lang.Object
com.skloch.game.SoundManager
All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable

public class SoundManager extends Object implements com.badlogic.gdx.utils.Disposable
A class handling loading, playing and disposing of sounds.
  • Field Details

    • overworldMusic

      public com.badlogic.gdx.audio.Music overworldMusic
    • footstep1

      private com.badlogic.gdx.audio.Sound footstep1
    • footstep2

      private com.badlogic.gdx.audio.Sound footstep2
    • footstepBool

      public boolean footstepBool
    • footstepTimer

      private float footstepTimer
    • sfxVolume

      private float sfxVolume
    • musicVolume

      private float musicVolume
    • pauseSound

      private com.badlogic.gdx.audio.Sound pauseSound
    • dialogueOpenSound

      private com.badlogic.gdx.audio.Sound dialogueOpenSound
    • dialogueOptionSound

      private com.badlogic.gdx.audio.Sound dialogueOptionSound
    • buttonSound

      private com.badlogic.gdx.audio.Sound buttonSound
  • Constructor Details

    • SoundManager

      public SoundManager()
      A class to handle playing sounds in the game, handles loading and playing of music and sounds so a GameScreen can just call "play overworld music" without needing to know the track title. Also handles disposing sounds and music
  • Method Details

    • setMusicVolume

      public void setMusicVolume(float volume)
      Sets the volume of the music
      Parameters:
      volume -
    • setSfxVolume

      public void setSfxVolume(float volume)
      Sets the sound effect volume
      Parameters:
      volume -
    • playPauseSound

      public void playPauseSound()
      A sound for when the pause menu appears
    • playDialogueOpen

      public void playDialogueOpen()
      A sound for when the dialogue box appears
    • playDialogueOption

      public void playDialogueOption()
      A sound for when the arrow in the selectBox is moved
    • playButton

      public void playButton()
      A sound for when a button is pressed
    • playOverworldMusic

      public void playOverworldMusic()
      Plays the music for the overworld (main game)
    • stopOverworldMusic

      public void stopOverworldMusic()
      Stops the music for the overworld
    • playMenuMusic

      public void playMenuMusic()
      Plays the music for the menu
    • stopMenuMusic

      public void stopMenuMusic()
      Stops the music for the menu
    • pauseOverworldMusic

      public void pauseOverworldMusic()
      Pauses the overworld music, so it can be resumed from this point later
    • getMusicVolume

      public float getMusicVolume()
      Returns:
      The current music volume
    • getSfxVolume

      public float getSfxVolume()
      Returns:
      The current sound effect volume
    • processTimers

      public void processTimers(float delta)
      Updates the timers for sounds that repeat regularly, needs to be called every render cycle. Specifically handles triggering footsteps when the player is moving
      Parameters:
      delta - Time passed since the last render
    • playFootstep

      public void playFootstep()
      Plays an alternating footstep sound when the player is moving and the footstepTimer variable has hit zero. Uses two different SFX to sound more realistic and to allow the timing to be configured
    • dispose

      public void dispose()
      Disposes of all music and sound effects
      Specified by:
      dispose in interface com.badlogic.gdx.utils.Disposable