Table of Contents
10. Sound Effects & Music
Series
You are reading Part 10 of the Space Shooter Tutorial.
Determine the beginning of the scene
Firstly, we will add soundtrack music to our game. This music will be played at the beginning of the game. Hence, we have to determine when the scene starts. We are using a built-in condition called “At the beginning of the scene.” So, open the Events tab and add a new event.
Playing sounds
Create a new action in the previous event. Type play on the search bar, and select Play sound. Add an audio file called “soundtrack.ogg” from the assets folder. Set the volume 40, and enter 1 as the pitch value.
Then, you should see:
Playing sound effects
We will add a laser sound effect that will be played when the player fires a bullet. Go to the FireBegin event. Add a new action to play a sound. Select “sfx_laser.ogg” from the assets folder, set volume to 100, and pitch to 1.
We will add an enemy hit sound effect, which will be played when the player hits the enemy. Go to the Enemies is collision with Bullet event. Add a new action to play a sound. Select “enemy_explosion.waw” from the assets folder, set the volume to 100, and pitch to 1.
Finally, we will add a sound effect that will be played when the player collects a powerup. Go to the Player's collision with powerup events. Add a new action to play a sound. Select “sfx_shieldUp.ogg” from the assets folder, set volume to 100, and pitch to 1.
That is all. You can test your sound effects by running the game.