Now we have music and sound effects working, but we are missing a very important point: allowing the user to disable them. If you add sounds to a game, you need to provide a way to disable them. Many people like to play in silence.
To do this, we will add two buttons on the main screen (one for music and one for sounds) to enable and disable each one independently. These options should also be present on the Pause dialog, but we will get into that when we rework the dialogs in the next chapter.
On the one hand, we are going to update the layout and the code of MainMenuFragment
; on the other hand, we will make SoundManager
take care of this configuration.
To store the music and sound state we will use SharedPreferences
, as it is the simplest and most convenient way to store key-value persistent data on Android.