arrow_back Crashing Sounds
In this add-on, I'll show you how to program your two sprites to play a crashing sound if they touch.
To code this, use an “if” block. When you’re done with this step, this “if” block will read, “if touching player 2, play a sound.”
To start, click on player 1. Then, click on events and select a "when green flag clicked” block to start. Next, go to control and select a “forever loop.’’ Inside of this "forever loop," I'll put an "if" statement, which is also found in control.
Now, program this to say: If touching player 2, play a sound.
Click on Sensing, and select a "touching" block and change the value to Player 2.
Now, you need a sound!
Click on the sounds tab, and select "choose sound from library."
This example uses “scream-male1,” but you can select whatever sound you want for your project.
you can select whichever sound you want for your project.
Click the “scripts” tab, select the sound menu, and choose “play sound scream-male 1 until done.” Then, place this block in your if statement.
Now, the code reads: “Once this program starts, if player 1 touches player 2, play the male-scream sound.” Let's try it!
(chuckles) Great! Now if the two players crash into each other, a cool scream sound plays. This is a fun add-on to try with someone else, so be sure to try your game with a neighbor!