Adding Background Music
Try reloading this page, or reviewing your browser settings
This video shows how to import audio files for sound effects and activate them during the game with events.
- Construct 2
- Sound Effects
About this video
- Lee Stemkoski
- First online
- 15 February 2019
- Online ISBN
- Copyright information
- © Lee Stemkoski 2019
Lee Stemkoski: In this video, you will learn how to import audio files including sounds for sound effects and longer background music tracks into Construct 2. This will enable us to provide audio feedback whenever the player’s character interacts with various objects in the level. And finally, we’ll load some background music that will help set the mood and tone of the game.
To begin, let’s open our project from last time. The first thing we’d like to do is to add an audio object. This is added in the same way we added the keyboard object towards the beginning of the project. The same way we add all objects, right click in the layout area and choose Insert new object. And in the category Media, select Audio and choose Insert. No cross hairs appears. This isn’t something visual you add to your level, but now we have an audio object which we can use in the Event sheet later.
Next, we need to import the various sounds and music we’ll be using in our game. So let’s go to the top right panel, the Layers panel. Let’s switch that back to the project view. So clicking on the Projects tab, we’ll see a list of everything in our game and everything’s organized into folders. We’ve added so many things. We’ll need to scroll down in this list until we see a folder called Sounds. Go ahead and right click on that folder and from the pop-up menu that appears, choose Import sounds. Now in our Jumping Jack assets folder, there’s an audio sub folder and this has a lot of sound effects. More than we actually are going to use in this project, but you have some options in case you want to try out some other sound effects on your own. So we’re going to select multiple audio files at once by holding down the control key.
So I’m going to select the win-trumpets sound for when we win the game. I’ll select the lose-trombone sound for when we lose the game. A jump sound for when the character jumps, a boing sound for a jumping off the springboard. A coin sound for when we collect coins. Item-pickup for when we collect items. A brick-break sound for whenever we break the bricks. A swoosh sound for when we unlock the lock boxes and hits sound for when we get hit by enemies and a poof sound for when the enemy has disappear. Again, holding down the control key allows us to select all of these at once. It’s very efficient rather than doing them each one at a time. Then choose the Open button. It’ll list all the sounds we’ve collected, and we’ll choose Import. Importing converts them to a format which can be used in Construct 2. When you’re done, click on OK.
And now, we actually proceed directly to the Event sheet. We’ll scroll up to the top and we’ll start adding in audio actions whenever we want to hear a sound. So for example, when we jump, this is our event number 3 when we pressed the J key, let’s add an action. This will be an Audio action. We have this because we just added the Audio object. And really, the only action we’ll ever use is the Play action. It’s first under the General category. In this case we’ll play the audio file jump. Next, let’s see when the Koala collects a Coin, let’s add an action here. This will again be an Audio action. Choose Play. We’ll play the coin’s sound. Also, when the game is over or right before that action, when the lose message displays, we’ll play that sad trombone sound. Let’s add an action. An Audio action, Play, audio file lose-trombone.
All right, scrolling down when the Koala collides with the Heart, let’s add an action. Audio, Play. In this case, we’ll just play a generic item-pickup sound. Same thing for when the Koala collides with the Clock. We’ll add an action. Audio, Play, item-pickup. When the Koala collides with a Springboard, we’ll add an action. This will be an Audio action, Play. We’ll play the boing sound this time. Let’s also add an action, a sound playing whenever you fall through platforms. So for this event, we’ll add another action. Audio, Play. Let’s play the swoosh sound. When the Koala’s overlapping the spikes, in this case, we’ll play the sound of getting hit. So Audio action, Play, hit. If the Koala’s health ever goes to zero, let’s add an action. Audio, Play, and this is a lose condition, so we’ll play the sad losing sound.
If the Koala collides with a Flag, so I’ll add an action, Audio action. Let’s play our winning sound. So winning-trumpet fanfare sound. If the Koala collides with a brick, let’s add an action. Audio, Play. In this case, the brick-breaking sound. If the Koala collects a Key, we’ll play or generic item-collect sound effect, item-pickup. The Koala is unlocking a box. In that case, we’ll play our swoosh sound effect. See, when the enemy turns around, we don’t need sound effects there. If the Koala destroys an enemy, we’ll play the poof sound effect as the enemy disappears. Finally, if the Koala gets hurt, again, we’ll play the hit sound effect.
There we go. A lot of sound effects. Let’s save and test this out and see how they sound. All right. Jumping, landing on a character, collecting coins, jumping off the trampoline. Collecting items, breaking bricks. Let’s try getting hurt. Oops, I didn’t actually get hurt in that case. It’s okay. I can go run into those spikes to see what that sounds like. Definitely sounds painful. Do the whooshing sound effect as we open these up and then, that sounds pretty good.