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 ...

Get Haxe Game Development Essentials 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.