Chapter 14. Sound and Music

Topics in This Chapter

14.1 Create Sound and Music Files

14.2 Load Music and Sound Effects

14.3 Specify Sound and Music Controls

14.4 Play Music

14.5 Play Music in a Loop

14.6 Play Sound Effects

14.7 Turn Sound On and Off

14.8 Conclusion

14.9 Exercises

Music and sound effects set mood and heighten realism, and thus are essential elements for video games. In this chapter we discuss how to play music and multiple sound effects simultaneously, as illustrated in Figure 14.1, which shows Snail Bait just before the runner is about to collide with multiple sprites, resulting in multiple sound effects.

Image

Get Core HTML5 2D Game Programming 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.