Package com.skloch.game
Class SoundManager
java.lang.Object
com.skloch.game.SoundManager
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
A class handling loading, playing and disposing of sounds.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate com.badlogic.gdx.audio.Soundprivate com.badlogic.gdx.audio.Soundprivate com.badlogic.gdx.audio.Soundprivate com.badlogic.gdx.audio.Soundprivate com.badlogic.gdx.audio.Soundbooleanprivate floatcom.badlogic.gdx.audio.Musicprivate floatcom.badlogic.gdx.audio.Musicprivate com.badlogic.gdx.audio.Soundprivate float -
Constructor Summary
ConstructorsConstructorDescriptionA 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. -
Method Summary
Modifier and TypeMethodDescriptionvoiddispose()Disposes of all music and sound effectsfloatfloatvoidPauses the overworld music, so it can be resumed from this point latervoidA sound for when a button is pressedvoidA sound for when the dialogue box appearsvoidA sound for when the arrow in the selectBox is movedvoidPlays an alternating footstep sound when the player is moving and the footstepTimer variable has hit zero.voidPlays the music for the menuvoidPlays the music for the overworld (main game)voidA sound for when the pause menu appearsvoidprocessTimers(float delta) Updates the timers for sounds that repeat regularly, needs to be called every render cycle.voidsetMusicVolume(float volume) Sets the volume of the musicvoidsetSfxVolume(float volume) Sets the sound effect volumevoidStops the music for the menuvoidStops the music for the overworld
-
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:
disposein interfacecom.badlogic.gdx.utils.Disposable
-