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 Surprise and Sell!


In this video, you'll learn how to surprise your audience with a sprite.

You will make a sprite appear during your commercial, move across the screen displaying a message, then disappear.

First, add a sprite to your project.

This example will use the dragon, but you can use any sprite you want.

Drag the sprite to the position on the screen where you want it to appear.

From the motion menu, add a "go to" block so the sprite will always start from this spot.

Drag the sprite to the position on the screen where you want it to stop moving.

The values in the “glide” block automatically update to match the sprite’s position.

Place a “glide” block under your “go to” block.

Test your code.

That looks good, but the dragon sprite doesn't fly all the way off screen.

Add a “hide” block after the “glide” block, and a “show” block before it so the sprite can only be seen when it is moving.

Try your code again.

That looks great!

Add a "When I receive" block to the top of the stack, and add a new message name like "surprise."

Test your code again by dragging out a "broadcast" block, setting the message to the one you just added, and watching that code under the "when I receive" block run.

When the message "Surprise" is broadcast, the "when I receive" block runs all the code under it, causing the dragon to appear on the left, then move to the right of the screen.

Remember, you must add the “broadcast” block with your new message somewhere in your commercial for this surprise sprite to appear.

Otherwise, the code under the "when I receive" block will never run.

This example adds the “broadcast” block to the text changing sprite, but you should add it wherever you want to trigger your surprise.

Try clicking the green flag.

Your surprise sprite should appear when the "broadcast" block is run.

Lastly, check out the special sounds included in the stage of this starter project.

Click on the Stage and then click the Sounds tab.

Drag any sound into one of your sprite icons to use it.

For example, drag the "Pew" sound from the stage into the dragon.

Now you can use this new sound when the surprise sprite comes onstage.

One of the great things about events is that they make it possible for multiple stacks of code to be run at the same time.

These code stacks can be in multiple sprites, so you could have lots of sprites come onstage as a surprise, or, multiple stacks of code can be in a single sprite.

With the code you see here, all the code stacks will start running as soon as the "Surprise" message is received, so the sprite flies on screen, plays a sound, says a message, changes color repeatedly, and turns all at the same time.

Now it's your turn.

Add a new sprite to your project.

Add code to make it fly across the screen, and add a "when I receive" event to make the code run.

Remember to add the "broadcast" block with the same message name as the "when I receive" block somewhere in your commercial so that your "when I receive" code stack will be run.

Tinker with all the values until you are happy with the results.

Choose an Add-On
Surprise and Sell!
Add a surprise sprite to your project.
Cool Company
Make your company name or message memorable with a special effect.
Catch a Break
Create a moving sprite for the audience to click on.
Call the Audience to Action
Tell your audience what to do next.
Buy Button
Add a button for buying your product.
Ask Your Audience
Ask your audience a question, and program a response.
arrow_backward Back
Next arrow_forward
  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!