O'Reilly logo

Haxe Game Development Essentials by Jeremy McCurdy

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

Creating sound constants

Now we're going to create a class that will contain constants for all of the music and the id attributes of sound we defined in the project file. We'll also create constants for our music and sound volume settings.

Creating the class

First, in the source folder, make a new folder named audio. Inside that folder, make a new class named Sounds. This class doesn't extend any other classes and doesn't need to import anything.

Here's what it should look like to start:

package audio;


class Sounds
{

}

Creating sound ID constants

Now let's add variables for each ID that we defined in the project file:

public static inline var MUSIC_FANFARE:String = "music_fanfare"; public static inline var MUSIC_INGAME:String = "music_ingame"; public ...

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