Skip to content

Please update your browser

Your browser version is not supported by this site. CS First may not work properly. Learn more.

Please note: This theme has not been updated to reflect Scratch 3.0. Visit this help article for more info.

4. Choose an Image

Transcript

In this video you will program the sprites to change costumes when the arrow keys are pressed.

This will let the user choose the items that appeal to them.

To start click on the Apparel Sprite.

Since the Apparel Sprite has different costumes you can change how it looks using the Next Costume Block.

Click on the Looks menu and drag this Block into the Scripts area.

Click it to see the different costumes for apparel.

To run this next Costume Block use an Event.

From the Events menu drag out a When Key Pressed Block.

Click the dropdown menu and change the key press event to the right arrow key.

Try it out.

Great!

Pressing the arrow key makes the Sprites Costume change.

This project has multiple Sprites, each with its own costumes and matching backdrop.

If you copy the code you just created to every Sprite it will all change costumes when the right arrow key is pressed.

The Sprite should change costumes only if their backdrop is shown.

For example, if the backdrop is the animals backdrop, then the arrow key should change only the animal costume.

To do this select the Control menu and drag an If Then Block around Next Costume.

If Then Block's run code if something is true.

Program the Apparel Sprite to change costumes if the Apparel backdrop is shown.

From the Operator's Menu drag an Equals Block into the If Block.

Drag a backdrop Name Block from the Looks menu into the Equals Block.

In the other space type the name of the backdrop Apparel.

The spelling must exactly match the name of the backdrop which you can see in the Backdrops Tab.

Great!

Now the Block Stack says If Backdrop Name equals or is the same as Apparel then go to the next Costume.

To test this click the flag, press the arrow key and choose Sprites.

Once you get to the My Page backdrop notice that the arrow key changes all the Sprites costumes except for the Apparel Sprites which you just programmed.

Now that you programmed one Sprite program the rest.

Select the animal Sprite.

Place an If Then Block around the next Costume Block.

Add an Equals Operator.

In one side of the Operator add a backdrop Name Block and in the other type the name of this backdrop, Animals.

This example will fast forward through this code for the other two Sprites.

Test out your program.

Click the Flag and press the right arrow key to change Costumes.

Choose the one you like best then click the Sprite to change to the next category.

When you get to the My Page backdrop all your image choices appear.

This is your chance to share your project with others and tell them how it works.

Write clear instructions so any Scratch user can play with your project and make it work.

Now it's your turn.

Program all the Sprites to go to the next Costume when the right arrow key is pressed if their backdrop is displayed.

When you're done click the green arrow to try some add-ons to customize your program.

arrow_backward Back
Next arrow_forward
Instructions
  1. Make the sprites rotate through their costumes.
  2. Make the sprites rotate through their costumes when the backdrop matches.