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

In this add-on, you will program the clone of a particular costume to play a sound or say something when it passes the object's sprite.

To start, program the clone to check which costume is displayed.

This example uses the peacock costume, but you can use any costume in your project.

Add a when I start it a clone block.

In this example, if the peacock costume is displayed, then the clone plays a sound and says something.

Add an if-then block.

Next, check if the costume number equals the costume you want to perform the action using the equals and costume number blocks.

Program an action that the clone will perform if the correct costume number is displayed.

Add a say block or a play sound block.

You can add both types of blocks or just one.

Type a message in the say block, or add a sound from the scratch library.

(Goose honking)

Select a forever block and place it around your block stack.

Click the flag and the right arrow key to test.

(Goose honking)

Great! The peacock plays the goose sound and says, "What's up?" but it keeps repeating this action for as long as it's on the screen which is annoying.

To fix this, program the clone to wait, until the dog has passed it.

Add a wait-until block, and a less-than block.

In the left side, add an x-position block from the motion menu.

In the right side, add an x-position block from the sensing menu.

Make sure the walking sprite's name is selected.

Now the code reads: If the clone's x-position is less than the walking sprite's x-position, meaning that the walking sprite has passed the clone, then play the goose sound and say "What's up".

Click the flag and the right arrow key to test.

(Goose honking)

(Goose honking)

Great! The peacock waits to play its sound until the walking sprite passes it.

But, after the walking sprite passes it, it keeps playing the sound until it's off the screen.

To make the clone perform the action only once each time it appears on the screen, duplicate the wait until code, and stack it on top of the original wait until code.

Tell the clone to wait until its x-position is greater than the walking sprite's x-position.

Then, wait until its x-position is less than the walking sprite's x-position.

This makes the clone wait until the sprite passes it before it plays its sound, then it won't play the sound again until the sprite is in front of it, and passes it again.

Click the flag and the right arrow key to test again.

(Goose honking)

(Goose honking)

Great!

Now it's your turn!

Program the clone to check which costume is displayed.

Check if the costume number equals the costume that will perform the action.

Program an action that the clone will do, if the correct costume number is displayed.

Program the clone to wait until the sprite has passed it.

Duplicate the wait until code stack and switch the order of the x-position box.

Choose an Add-On

Walk to the Beat

Play music when the character moves.

Passing By

Program the objects being passed to respond to the character.

Scenery Change

Set costumes to a random color when they appear.