Enabling and disabling music and sound FX

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.

Note

Always provide a way for the user to disable music and sound effects individually.

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 ...

Get Android Game Programming: A Developer’s Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.