Creating interactive mad libs in Scratch
Hide and Show Variables
Listing 2 hides all the Stage monitors, and the last block in the stack assigns the sound4
variable a value of 0
. The script in Listing 3 then checks the value of sound4
. This error-handling check prevents the user from displaying the story before all the words are collected. The when Sprite1 clicked
block (Listing 3) makes the cat clickable and is a user-initiated way to advance the story.
After the script collects the four words from the user, the cat instructs the user to click on it to create and display the story. The script checks to see if sound4
is equal to 0
. If that statement is true, nothing will happen when the user clicks on the cat, as represented by the empty if
statement. If sound4
is not 0
, then the cat hides while enabling all the reporter blocks so that the words stored in the variables display on the Stage. A create story
broadcast is fired off and received by all 12 story sprites simultaneously.
Create Story
When each sprite in the story receives the create story
broadcast, it will show
itself; then, the sprite will hide
itself when the user starts the project by clicking the green flag:
After you create a script for one story sprite, you can copy the script to other sprites by dragging and dropping it onto each of the 11 other story sprites. As you run through the story a few times, you can adjust the spacing of the sprites and the Stage monitors to try to create a readable story, regardless of what the user enters.
« Previous 1 2 3 4 Next »
Buy this article as PDF
Pages: 4
(incl. VAT)