SWL+Lesson+4+Create+a+Music+Sprite

=SCRATCH Lesson 4: Create a Music Sprite In this lesson 3, we make our sprite dance. In lesson 4, I will show you how to make him dance to the beat. And not just to the beat but to the Hip-Pop beat! = media type="file" key="Scratch Lesson 4_ Sprite Interactions via Variables med.mp4" width="780" height="418"

**Step 1: Create a Music Sprite** Let’s create a Music Sprite or a sprite that controls playing and stopping of background music. To create a new sprite, click to open Paint Editor. Instead of drawing our own, this time we will import an image. Click “Import”. Click “Costumes” if it’s not already selected. Then open “Things” folders. Select “drum1” or whatever image you like. Then click “OK” to save. Rename this new sprite to “hip-pop”. It’s seems big for me so I shrink it with “Shrink Sprite” tool. Then use “Move” tool to move the “hip-pop” sprite to wherever you see fit. I place it next to dancer1’s feet. Step 2: Move Music Loop to the Music Sprite Drag the Music Combo Block from dancer1’s Scripts Tab. Drop it to be over sprite “hip-pop” icon. Wait until the “hip-pop” sprite is highlighted before releasing the mouse. Sprite “hip-pop” now has the music combo block from “dancer1”. Delete this same combo block from “dancer1”. Step 3: Turn Music On and Off To turn music on and off, we need to create a virtual switch. Like a real switch, a virtual switch can be on or off. To create a virtual switch, we use Variables. Select “Variables” Tool Box, and click “Make a variable” button. Then enter “switch” for Variable name. I would like this switch to work this way:


 * < When the animation first starts, the music is playing and the switch is on. Click the “dancer1” sprite to turn it OFF, and click the “hip-pop” sprite to turn it ON again. If the switch is ON, music is ON; if the switch is OFF, music is OFF. ||

For this switch to work, we need following blocks: For sprite, we will add three new combo blocks. The first combo block turns the switch ON (set music on to 1) when is clicked. The second combo block turns the switch ON again (set music on to 1) when “hip-pop” is clicked. Finally, the third combo block keeps checking if the switch is OFF (switch = 0). If OFF, then stops all sounds. For sprite, we will add one combo block. This combo block will turns the switch OFF if “dancer1” is clicked. Your “dancer1” sprite should have these combo blocks. Your “hip-pop” sprite should have these combo blocks.
 * one [[image:https://lh3.googleusercontent.com/0RSyENZCulHVoJ0KnBnbm1ZBVD1bhibokkqIWxhYZCkJN7-qnYYvZW7byqs0X6R4OYcxZhBW-xnVjF4lk0MTwqaK7bRJ82OpfXmHm-CfD3aS4vQJBpQ width="65" height="25"]] block from [[image:https://lh4.googleusercontent.com/S_oDDG-WWKF7erYoREOKhNEtyxo8VKxDdIQfSDCRD_qqsokQto4ETORzOaJRfR9d2LbNBTevPdj2hag6t70aaxJsg1EIzAufZYL8DMHEbNp8a3PUjEE width="91" height="26"]] tool kit
 * one [[image:https://lh6.googleusercontent.com/vpUYSiMrkfO4n_7zJkcB3sHyrcgUUl5r8fQfev5bCM-7eOdOGLef4yJEfvuzcyZuKpvBkZYsgwhvdC8HKFs1fk05hQb3ubnGeLdaS84KSH-kcWBjWNA width="109" height="51"]] block from [[image:https://lh3.googleusercontent.com/yUws6acUuDspZvWL9PFZY3k5bDTCjscgCE9Vxd07AWnnODj9Ljq9KPL34b2jollwveYzYyqtegW84IFnb0L0WJAoSN7Vb-uYZSjTKPMj9BFsZeK5W9U width="90" height="22"]] tool kit
 * one [[image:https://lh5.googleusercontent.com/BBwIUbSc1fyR5eZZHfyTt-mkktTN3TlwbraATsmEUDMVFjomB3eVZVW4H9scy33wb7ymshswBx27b959bMjg4Y3WWwBlMS_sKoWcKG9Z3GUit6uemZE width="51" height="21"]] block from [[image:https://lh6.googleusercontent.com/NN5k6MfIWHbE_c9jah9DVRScfWeHF1V3tdbhc1I9FegKPf5nxrNitJJ432Y68f5rdx8rjZFCTrbCCgfqio_KJpfCUyJ3PEZjNJZ70csvKpTx9Fc9jbk width="92" height="19"]] tool kit

= Link to Lesson 5 =