Scratch exercise 49

Randomly select a sprite's costume from a range of costumes

It this tutorial you will learn how to select a costume when the game starts, and then make Scratch select a random costume from a range of costumes when you press a key.

 

1. Create a new game. Either open Scratch or if it is already open choose "File>New" ..

 

 

2. Delete the cat by right-clicking on the sprite thumbnail below the stage.

 

 

3. Create a sprite with multiple costumes. In this example we have a simple circle with 5 costumes ..

Note that as well as a name, each costume has a costume number (costume#) to the left of its thumbnail image.

 

 

4. Add these scripts to the sprite ..

 

 

5. Press "B" to start your game and "C" to switch to a random costume (costume#) between 2 and 5.

 

 

6. Use "File>Save as" to save your game. Name it "random costumes".