Skip to content

Please update your browser

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

2. Fragen und Antworten

Transcript

On day 2, you used a “say” block to create dialogue. The “say” block in Scratch makes a character say something. However, it cannot receive a response from the audience. The “ask” block also makes a character say something. Unlike the “say” block, however, it collects an answer from the audience using a text box. You will make your story interactive using the “ask” block.

To get started, click sensing, and drag out an “ask” block.

Test the block by clicking on it. You’ll see that the sprite asks “What’s your name?” and a box pops up at the bottom of the stage.

Click the stop sign to stop this code, then change the text of this question to something like, “Would you like to go through the secret door?”

Test this again. You’ll notice that again a text box appears where a user can type his or her answer. The text a user enters in the box is stored in a variable called “answer.” In computer science, a place in the code that stores a value, or information like user text, is called a “variable.”

Click the checkbox next to the answer variable to see what’s stored there. To test it, click the “ask” block, then type an answer and press “enter” on your keyboard. You should see the answer you entered stored in the answer variable. If you run the code again and enter a different answer, the new answer will replace the old one.

In the next video, you’ll program your story to make a decision based on the audience’s answer.

arrow_backward Zurück
Weiter arrow_forward
Anweisungen
  1. Stellt dem Nutzer eine Frage.
  2. Probiert ein paar verschiedene Antworten aus.