Adding music to the menu
In this topic, we're going to create a mute button which will control our menu's theme music. Pressing the mute button will cause the music to either play if currently paused, or pause if currently playing. This method for muting music and sounds can also be applied to in-game options and other areas of a game which allow sound and music playback. The difference between this recipe and the previous, is that we're going to be using a TiledSprite
object which will allow us to set the Sprite
object's tile index depending on whether the sound is playing or paused. Keep in mind that this recipe is useful for more than just enabling and disabling menu music. We can also follow the same approach for many other toggle-able options and states during gameplay.
Getting ready…
This recipe requires basic knowledge of the Sprite
object in AndEngine as well as using touch events to perform actions. Additionally, since we'll be incorporating the Music
object into this recipe, we should...