Scratch exercise 103


In this tutorial you will create 4 interactive buttons that depress and click when you click on them with the mouse.


Complete these steps ..


1. Create a new game (from the top menu choose "File>New").


2. Right-click the cat thumbnail (sprite1) under the stage to delete the cat sprite.


3. Download and save these images ..


4. Let's start with the blue button. Use the "choose new sprite from file" button under the stage and add the "blue-button-up.png" image as a new sprite to your game.

Next, switch to the sprite's "Costume" tab and import "blue-button-down.png". Re-name the sprite "blue button" ..


Do the same for the red, green and yellow buttons ..


5. Download and save this MP3 audio file of a button click sound ..


Now, select each button in turn, click on the "Sounds" tab, then import "button-click-1.mp3".


6. Use "File>Save as" to save your game. Call it "buttons".


7. Select the stage and then create these variables "for all sprites" ..

You will use these variables to help arrange the buttons in a row on the stage.


8. Add these scripts to the stage ..


9. The scripts for the four buttons are almost identical. Select the "blue button" and add these scripts ..

Leave the broadcast blank for now. You will use this to create your own broadcast when you decide what you want the button to do.


10. Duplicate the scripts to the "red button" and edit the "set x to .." script block so the red button is positioned to the right of the blue button, like this ..


11. Do the same for the green and yellow buttons ..


12. Test your game by switching to full screen mode, pressing"B" to begin your game, and then clicking on the buttons. If all the buttons are working, use "File>Save" as to re-save your game.


13. Well done, you're finished! Now, create your own sprites and use the buttons to control them in some way.