In this chapter, we have learned how to use Libgdx's four audio interfaces, Sound
, Music
, AudioDevice
, and AudioRecorder
, and about their specific use cases. We have taken a look at freely available and open source sound generators and used one of them to create sound effects that can be used in Canyon Bunny. We have also added background music to the game and understood that Libgdx takes care of when a music instance being played needs to be paused and resumed in terms of the Life-Cycle in a Libgdx application. A manager class called AudioManager
has been created to gain centralized control over any audio-related actions. Finally, playing music and sounds turned out to be a very straightforward process in conjunction with the use of our audio manager. We had to add just a few new lines of code to trigger the music and sound effects at the right time for each event.
In the next chapter, we will have a look at some advanced programming techniques. This includes using a physics engine...