Game Development Reference
In-Depth Information
The volume member variable is generally a value between 0 and 1, where 0 means no sound, and
1 plays back the sound at full volume.
Technically, there is no difference between background music and sound effects. Normally,
background music is played at a lower volume; and many games loop the background music so
that when the song ends, the audio is played from the beginning again. You see later how to do that.
All the games you develop in this topic use both types of sound (background music and sound effects)
to make the games more exciting.
Note You need to watch out for a few things when using sounds and music in your game. Sound can be
annoying to some players, so if you do use sound effects or music, make sure there is a way for the player to
turn them off. Also, don't force players to wait until a sound has finished playing before they can continue. You
might have composed a great song that you want to play while the introduction screen is shown, but players
don't launch your game to listen to your music—they want to play! The same principle holds for in-game
video sequences. Always provide a way for the user to skip those (even if you got your favorite family member
to provide the zombie sounds). Finally, loading sounds and music can take time, especially when the files are
hosted on a web site. Try to use small sound files whenever possible.
What You Have Learned
In this chapter, you have learned:
How to load game assets such as sprites and sounds into memory
How to draw multiple sprites on the screen and move them around
How to play background music and sound effects in your game
 
Search WWH ::




Custom Search