Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
The next step in the development of this game is I really want to bring it to life with some audio, and the perfect place for some audio is just when these explosions happen. Other than that, I don't want to add a lot of audio, because we have to remember this is a mobile game and with all of this audio playing, they could be again in line to get sandwich out in the public or something like that, and they might would not want all of the this audio coming from their phone. Or they could be even listening to music through their phone as well. So use your audio sparingly.
In this case, it's just going to be for these explosions. All right, I'll close that file, and let's go into the Library panel because notice there are a couple audio files. There is this explode.wav, for instance, and this is the file that I want to use. In fact, with this selected, what I can do is I can hit this little Play button right up here, and that's what I want to play when that explosion happens. Notice its linkage name is Explode, so I want to reference that, and let's just go ahead and go into our Actions panel for that first frame in the Actions layer.
And when I am going to add this explosion sound is going to be in this function on line 255. When I make that explosion, that's when I want to go ahead, and right in here, I want to sort of play an explosion sound. Let's go ahead and take a look at our Library, because I am going to be pulling this item from the Library. So I am going to say variable. I am creating a new variable, and I am just going to call it sound: and it's of Sound type, so that's the type it is.
It's a sound file is what I am using. But I am creating a new explode instance from this item in my library. Now it's known as sound, that particular one, so I can go ahead and the next line, I can type in sound.play. Now there is many other things you could do with the sound class and various sound items, but again, what you want to do with the sound is you want to use it really sparingly, and that's what I am doing here. I am just going to use it here. Notice there is also this shoot.wav file in here, and I could use that for the laser, but that laser is being fired off every half of a second so it gets a little annoying, to be honest with you.
But with this implemented, I can go ahead and do a test movie. And now, let's check that out. I am going to click Play and try to shoot the UFOs, and we should hear that explosion. (explosions) So sound is that simple, as simple as writing two lines of code and making sure it's in your library.
Just use it sparingly, but you can see how it really brings your game to life.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 98181 Viewers
61 Video lessons · 85482 Viewers
71 Video lessons · 69439 Viewers
56 Video lessons · 101790 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.