After the first video, you wrote scripted responses
to planned interview questions.
an athlete might not have something planned
to say in response to an interviewer's question.
This add on will show you how
to have the user give the answer
to an interviewer question.
To start, select the interviewer sprite.
From the Sensing menu, drag out an ask block.
The ask block works like the say block
but rather than simply saying words,
it also allows a user to type a response into a text box.
Click on the ask block to see what it does.
The box shows up at the bottom of the stage.
Type some text in the box, then press enter.
The variable named answer now has the value
of what you typed.
To see what is stored in the answer variable,
click the check box next to answer.
You'll see the answer you just typed.
Use an ask/answer pair to ask an interview question
and have the user type an answer.
Place the ask block at the end
of the interviewer sprite's code stack.
Type a question into the blank in the ask block.
In this example, the interviewer sprite asks,
"What contributed to your success in this club?"
Run the code.
The interviewer asked the question,
then the box for the answer shows up.
Any code blocks after the ask block won't run
until the user types an answer and presses enter.
Next, let the athlete sprite know when the user has finished
typing the answer using a broadcast block.
From the Events menu, place a broadcast block
under the ask block.
Open the drop down and click new message.
Name the message something that makes sense like,
answer the question, then click okay.
Now, have the athlete sprite repeat the answer the user gave
to the interview question.
Select the athlete.
From the Events menu, drag out a when I receive block.
From the drop down, select the message you created.
Under this block, make the sprite say the answer
that the user typed.
From the Looks menu, place a say block
under the when I receive block.
From the Sensing menu, place answer inside the say block.
Test the code.
The interviewer asked the question
and a box pops up on the stage.
You type the answer, press enter,
and the athlete says the answer you typed.
Alright, here's the game plan.
Add an ask block with a new question
to the interviewer's script.
Put a broadcast block with a new message
below the ask block.
Make the athlete say the user's typed answer
when it receives the broadcasted message.
Make the user answer an interview question!
Program a sprite to pop onto the stage and interrupt the interview.
Dump Gatorade on your athlete's head.
Have fans take pictures of the victorious athlete.
Sign in to track your progress and earn badges