Skip to content

Please update your browser

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

arrow_back Mystery Box (Part 1 of 2)

Choose an Add-On
Change Setting
In this add-on, you will change your story’s setting.
Mystery Box (Part 1 of 2)
Animate a mystery box to appear!
Mystery Box (Part 2 of 2)
Animate a mystery box to appear!
Animate the Narrator (Part 1 of 2)
Animate the narrator to talk!
Animate the Narrator (Part 2 of 2)
Animate the narrator to talk!
Play a Song
This add-on will show you how to use Scratch to create your own song.
Add Another Character
In this add-on, you add another character to your story to spice it up!
  • 1. Introduction to Characterization and Broadcast
  • 2. Using Actions to Learn About a Character
  • 3. Broadcasting Messages
  • 4. Characters on Parade
  • 5. Broadcasting Your Own Message
  • 6. Add-Ons
  • 7. Reflection
  • 8. Wrap-up: Characterization
  • 9. Wrap-up: Share Your Project
  • 10. Wrap-up: Show Your Project
arrow_backward Back Next arrow_forward

In this two-part add-on, you’ll program the character to react to something inside a box. Click the “box” sprite, and look inside the “costumes” tab. This sprite has a costume that looks like a closed box, a costume that looks like an open box, and a bunch of costumes for what could be inside the box.

In this video, you’ll only use the “open” and “closed” box costumes. To animate the box opening, add code to make this sprite change costumes from the closed box to the open box. Click the “scripts” tab. Open the “looks” menu, and drag out a “switch costume” block. Select the “closed box” costume from the dropdown menu. Click this block to test it. Nothing seems to happen because the sprite is hidden. Snap a “show” block under the “switch costume” block, and test again. Great! A closed box shows up. Move the box to where you’d like it to appear on the screen-- this example puts the box in the lower left corner.

Next, animate the box to open. Add another “switch costume” block to the end of the stack. Choose the “opened box” costume from the dropdown menu. Click the new block to test. Hmm.. now the box is open when the program starts! That’s because the costumes are switching so fast that you never see the closed box. To fix this, open the “control” menu, and add a “wait” block before the second “switch costume” block. Click the flag to test. Great! Now the box stays closed for a second, then opens. Tinker with the value in the “wait” block to control how long the program waits until the box opens.

Next, make the character react to the box opening. To do this, broadcast a message to the character sprite telling it how to react. Open the “events” menu, and add a “broadcast” block. Choose a reaction from the dropdown menu. In this example, the character will dance in excitement, but you can use any reaction that fits the personality of your character.

Click the stack to test it out. Great! When the box opens, the character reacts.

Next, make this animation part of your story. Click the “narrator” sprite. Add some dialogue using a “say” block to set up opening the box.

Then, add either a “broadcast” block or a “broadcast and wait” block. A “broadcast and wait” block tells the program to wait until the box animation finishes before running any other code. The “broadcast” block keeps the code running while the box opens. This example uses a “broadcast” block.

Open the dropdown menu, and click “new message.” Type a message that describes the box animation, like “open box,” then click “OK.”

Then, click the “box” sprite, and add a “when I receive” block on top of the stack you programmed. Select your new message from the dropdown menu.

Click the flag to test out the story.

The narrator talks, and the box animation appears.

Great! Now, it’s your turn!

Animate the box to open using “show,” “switch costume,” and “wait” blocks.

Program the character to react using a “broadcast” block.

Hide the box at the end of the animation using a “hide” block.

Make the box animation part of the story by adding some dialogue and a “broadcast” or “broadcast and wait” block to the narrator sprite, and a “when I receive” block to the box sprite.

In part 2 of this add-on, you’ll program objects to come out of the box!

  1. Choose an Add-On, and click "watch" to learn how to build it.
  2. Once you finish one Add-On, try another one below the video!