Skip to content
Transcript

In this video you'll keep the lens from describing anything but the model.

The code you created so far checks only to see if the color the lens is touching matches the color in any of the conditionals or if then blocks.

That means if the backdrop for the sprite is purple and the lens clicks on the backdrop, the lens starts to say the text for the purple shirt.

This is a bug, or unexpected behavior in the code.

As a computer program gets longer with more code and more if then decisions even the most experienced computer scientists are unable to predict every behavior that will happen so they test their code often and tinker with it to find and fix the bugs.

Fix this bug so the lens shows text only when the model sprite is clicked.

Select the control menu, drag out an if then block and place it around all if then blocks that check the color being touched.

From the sensing menu drag out a touching block and place it in the if then block.

Choose model from the drop down.

Now the code reads, "If the lens is touching the model, "then run the other if then blocks that check the color and show text."

If the lens sprite is not touching the model sprite the if then blocks never run at all.

Try it out.

Great, in this example, when the purple backdrop is clicked the description for the shirt does not display.

When the model's purple shirt is clicked the description does display.

Add a backdrop for your sprite too.

Lastly give the user of your project instructions about how to explore.

Click the model sprite, use the when flag clicked block and say blocks to introduce your project and tell the user how it works.

Write your own introductory text.

This is just an example.

Now it's your turn.

Add an if touching model block around all the color conditionals in your project so that the lens does not describe the outfit when the backdrop is clicked.

Add a backdrop to your project.

In the model sprite, add instructions that tell the user how your program works.

Instructions
  1. Use an "if/then" block to prevent the lens from reacting to the backdrop.
  2. Add a backdrop.
  3. Introduce your project using "say" blocks.