Time for action — adding sounds
After our short break away from it, we return to put the final ingredient in our platformer: sound.
1. Record or find sound effects for, the actions jumping, dying, winning, and hitting an enemy. Name these sound effects
Jump.wav, Die.wav, Win.wav
, andHit.wav
accordingly. A useful free tool for recording retro sound effects is SFXR.2. Copy these sound effects to the project folder and open
MyPlatformer
up again, entering the Event Sheet Editor.3. To start, we'll play a sound whenever the player jumps. Add a new event to the event sheet. Select the
Player
object and from the Platform tab, choose the condition Is jumping and click on Finish. Then complete the event with aTrigger once while true
condition.4. Now add an action for this event from the
XAudio2
object. Select the highlighted actionAutoplay file
and click onNext
. Enter the textAppPath & "Jump.wav
", and click on Finish to see a display similar to the following screenshot:5. Next, add another...