O'Reilly logo

Mastering Android Game Development by Raul Portales

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required