Skip to content

Please update your browser

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

4. Nur das Model beschreiben


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. Click 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 dropdown. 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 project works.

arrow_backward Zurück
Weiter arrow_forward
  1. Verwendet den Block “falls/dann”, um zu verhindern, dass die Linse auf das Bühnenbild reagiert.
  2. Ein Bühnenbild hinzufügen.
  3. Stellt euer Projekt mit Blöcken „sage“ vor.