Time for action — adding the sounds and music
We want to give our player some added feedback, so we'll be playing sounds when certain events happen in the game.
1. First, we'll need our sound and music files. Create or find an MP3 song you'd like to loop in the background and name it
Game.mp3
before moving it into the same folder as the project source.2. Next, create sound effects for when the ball is launched, hits a peg, lands in the free ball bucket, hits a combo peg, touches a portal, and when the game is won or lost. Name these
Launch.wav, Peg.wav, FreeBall.wav, Combo.wav, Portal.wav, Win.wav
, andLose.wav
respectively. Place these in the project source folder as well.3. Return to the
Game
event sheet. In theStart of layout
event, add the highlighted action Play music from file for theXAudio2
object and enterAppPath & "Game.mp3
".4. Add another action to loop the music from the
XAudio2
object, as in the following screenshot:5. Scroll down to event 6 (the event that triggers when...