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 Secret Item

Transcript

In this add-on, you will add a surprise feature to your program.

When the user presses a certain key, your surprise item will appear on the screen.

The user can then place that item anywhere on the image.

To begin, select a sprite to be your secret item.

You can select a sprite from the Scratch library or from the "Additional Scratch Images Project" by adding it to your backpack.

Access the Additional Images Project by clicking the link next to this video.

Click the triangle at the bottom of the scripts area to open your backpack.

The backpack is attached to your username, so as long as you’re signed in, anything that you put in it can be used in your other projects.

To copy a secret item to your backpack, select the secret item sprite and click the costumes tab.

Select a costume, and click and drag it to the backpack.

This example uses the mustache, but you can select any item you'd like.

Return to the tab for your Scratch project.

Refresh the page to show the contents of the backpack.

Open the backpack.

Then, drag the costume into the sprites area.

If you are copying a sprite, drag the sprite into the sprites area.

If you need help using the backpack in Scratch, ask your neighbor or put up your sticky note to get your Guru’s attention.

To make the item a secret, add the "hide" block from the looks menu to the scripts area.

Then, add a "when flag clicked" block to the top of the code stack.

Now, when the flag is clicked, the sprite disappears.

Allow the user to press a key to make the sprite reappear by adding a keypress event.

From the dropdown menu, select any event you like.

This example uses the space key.

Add a "show" block to your event.

When the user presses the key you selected, the sprite appears.

Wait a second, the sprite is still hidden!

If this happens, it could mean that the sprite is behind another sprite.

To make sure the sprite shows, add a "go to front" block.

Try it out.

This looks okay, but it would look better if the sprite followed the mouse pointer until it gets to where you wanted to place it.

To make this happen, add a "go to mouse-pointer" block from the motion menu.

This works, but you have to know exactly where you want to place the sprite when you press the key.

To make the sprite follow the mouse-pointer until you are ready to place it, put a "repeat until" loop from the control menu around the "go to mouse pointer" block.

Drag this under the "go to front" block.

From the sensing menu, add a "mouse down" block.

Try it out.

The sprite follows the mouse pointer until you click the mouse to place the sprite on the image.

Now it's your turn: Add an image to be your secret item from the Scratch library or from the Additional Images Scratch Project.

Program the item to hide when the flag is clicked.

Finally, program a keypress event to make the item show and follow the mouse pointer.

Choose an Add-On
On to the Next One
Enable the user to scroll through different images using a keypress event.
Custom Filter
Create your own unique filter.
Secret Item
Add a surprise feature to your program
Choose Image Category
Program a dropdown menu to give the user a chance to pick the image category displayed [Note: to complete this add-on, you'll need to have already programmed all three image sprites from 4. Choose Your Image.]
Talking Pictures
Make the images respond to specific effects.
Sound Effects
Add sound to your project.
arrow_backward Back
Next arrow_forward
Instructions
  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!