Music and Sound
In this tutorial, we’ll learn how to add music and sound to your game, enhancing the player’s experience with audio effects and background music.
Adding the Game Assets
First, we need to add our music and sound files to the game.
- Navigate to
Game assets > Music/Sound
. - Click
+ New sound
and drop your sound file. - Repeat these steps to add your music file.
Playing Music
Now, we’ll set the background music to play in the game.
- Navigate to
Maps > Map 1 > Events
. - Click
+ Event
and add theSet background music
event. - In the event configuration:
- Select the music asset we added.
Head to Play test
and you should hear the background music playing.
In your game, you can control when the background music changes or stops by using the Set background music
and Stop background music
events.
Playing Sound
Next, we’ll create an event that plays a sound when the player walks over a specific area.
- Create a new event group and name it “Play sound”.
- In the event group:
- Add the
Play sound
event and select the sound asset we uploaded.
- Add the
Adding the Event Group to the Map
- Navigate to
Maps > Map 1 > Events
. - Add the “Play sound” event group to the map.
- Set the trigger to
Touch
. - Place the trigger in the desired location on the map.
Play Test
Now, play test the game by walking over the event group we added, and you should hear the sound play! Every time you walk over it, the event group will trigger and the sound will play.