In this screencast, you'll learn how to add sound effects to your projectile sprite soit makes a noise when it touches your main character sprite. Watch this screencast tolearn the steps, and then try them out. The starter project already includes a "makenoise" block, but it doesn't do anything yet because it has not been defined. If you rememberfrom day 1 of this club, when you create a custom block or process, you also need totell the computer what it should do when the block is used. Drag out a “play sound”block and place it under the “define make noise” block. Choose one of your soundsfrom the drop-down. Run the code to see what happens. Perfect! The sound plays when theprojectile sprite hits the main character sprite.
But, you want the sprite to make a different noise for each of its four costumes. To makethat happen, use an if-then statement from the control menu. This statement needs tocheck IF the costume equals a certain costume number, THEN play a sound. To create thatcode, click on the operator menu and put an “equals operator” block inside the ifstatement. Under the looks menu, drag the “costumenumber” block into the “operator” block, and type a "1" into the white value box ofthe operator block. The code now reads: "If the costume number equals 1, then play a certainsound." Try it out. Nice! In this example, if the costume is number 1, the bird, thenthe bird sound plays. Otherwise, no sound plays at all.
You want a sound to play for each costume, so right-click on the If statement and chooseduplicate, then change the values of the costume number and the “play sound” block. Thiswill make a different sound play for each costume. You can always click back on thecostumes tab to check the number of a particular costume.
Now, it's your turn. Add an If-then block to the “define make noise” stack, andcreate code that says "If the costume equals 1, then play a sound." Do this for all fourof the projectile sprite’s costumes so each plays a different sound. Remember, if youget stuck, ask your neighbor or put up your sticky to get the attention of your CS First Guru.