You are currently using an older browser. Please update to the latest browser to ensure features and pages work properly. Learn more
4. For the Model Only
In this video you'll keep the lensfrom describing anything but the model.
The code you created so far checks only to seeif the color the lens is touchingmatches the color in any of the conditionalsor if then blocks.
That means if the backdrop for the sprite is purpleand 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 longerwith more code and more if then decisionseven the most experienced computer scientistsare unable to predict every behavior that will happenso they test their code often and tinker with itto find and fix the bugs.
Fix this bug so the lens shows textonly when the model sprite is clicked.
Select the control menu, drag out an if then blockand place it around all if then blocksthat check the color being touched.
From the sensing menu drag out a touching blockand 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 blocksthat check the color and show text."
If the lens sprite is not touching the model spritethe if then blocks never run at all.
Try it out.
Great, in this example, when the purple backdrop is clickedthe description for the shirt does not display.
When the model's purple shirt is clickedthe description does display.
Add a backdrop for your sprite too.
Lastly give the user of your project instructionsabout how to explore.
Click the model sprite, use the when flag clicked blockand say blocks to introduce your projectand 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 blockaround all the color conditionals in your projectso that the lens does not describe the outfitwhen the backdrop is clicked.
Add a backdrop to your project.
In the model sprite, add instructions that tell the userhow your program works.
Use an "if/then" block to prevent the lens from reacting to the backdrop.
Add a backdrop.
Introduce your project using "say" blocks.
Sign in to save your project and track your progress.