Page 10 of 15
Adding Music
To improve the atmosphere we are going to add background music to the game. Click again on the button to add a sound. In the form give the sound an appropriate name and press the Load Sound button. You should still be in the folder with the sounds for the tutorial. Select the file music.mid. This is a midi file. These are useful as background music as they are rather small. Many can be found on the internet. Press OK to close the sound form.
Now we need to make sure that the sound will play at the beginning of the game and loop forever. We are going to use an additional object for it. Press the button with the blue ball to add a new object and give it an appropriate name. It does not need a sprite. Click on the Add Event button and select the Create event. At the right side select the page main1 and drag the Play Sound action into the action list. (You should by now know how this works.) As a sound select the music and set loop to true. So the music will now play forever after the object is created.


Press OK to close the action form and again press OK to close the object form. We still need to add the object to the room, otherwise it won't be created. In the list at the left double click on the room to open its form. Make sure the objects page is visible at the left. Click on the menu icon in the middle to select the music object. Now click somewhere in the room to add an instance of the object. The object has no sprite so a little blue ball with a question mark is shown instead:


Be careful to only add one instance of the music object. Press the green checkbox to close the room form. Save the game and run it. You should now hear background music.