HTML and CSS Reference
In-Depth Information
Adding sound effects
In this task, we will add sound effects to the game.
Prepare for lift off
We want to ensure that the SoundJS library is ready in the
vendors
folder. If the file is missing,
we can find it in the CreateJS website or the code bundle.
We also need to have the following sound effects files prepared in the
audio
folder. There
are sound efects to start the game, click on a buton, trash sushi, and earn money.
Engage thrusters
In the following steps, we will add sound effects to our game:
1. Let's begin by loading the audio file. We add the following sound-loading code into
the
game.js
file:
game.load = function() {
// begin loading content (only sounds to load)
var assetsPath = "audio/";
manifest = [
{id:"button", src:"button.ogg"},
{id:"refill", src:"refill.ogg"},
{id:"earn-money", src:"earn money.ogg"},
{id:"start-game", src:"start game.ogg"}
];