Chapter 5. Adding Sound

In this chapter, we're going to add music and sound effects to make our new animations and gameplay really stand out. Good sound effects can make even simple animations have more punch, and music will focus players and keep them engaged. Luckily, OpenFL and HaxeFlixel make implementing music and sound incredibly easy.

Here's a rundown of the sections in this chapter:

  • Project updates
  • Creating sound constants
  • Building the sound manager class
  • Adding music
  • Adding menu sounds
  • Adding gameplay sounds

Project updates

To start, we'll update our project by adding the new sounds to the game. Then, we'll add a new section to our project settings XML file.

Adding new assets

In the assets folder, make a new folder named audio. Copy all of the new ...

Get Haxe Game Development Essentials now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.