Skip to content

In this video, you'll add a sprite that bounces around the screen, and makes a special offer to the audience watching your commercial when the user clicks on it.

First, add any sprite to your project.

To make the sprite bounce all over the screen, add a go to block, and two pick random operator blocks with the height and width dimensions of the stage as the x and y values.

Try that out.

Each time the block is clicked the sprite hops from one spot to another on the screen.

Add repeat and wait blocks to make the sprite jump around the stage many times, pausing between each jump to give the user a chance to click it.

Tinker with the values in the repeat and wait blocks until you like the way the sprite moves.

The higher the number in the repeat loop, the more times the sprite will move around the screen.

The higher the number in the wait loop, the longer the sprite will pause in one place.

Higher numbers will make it easier for your audience to click on the sprite.

Lower numbers can make the sprite hard to catch.

Remember to try your code often.

Drag out a say for two seconds block, and enter the instructions the sprite should say when it first appears on the screen.

This example says, catch me for a free gift!

But you can enter any text you like.

If the sprite stays in one place while it gives the instructions, it'll be very easy for an audience member to click on it.

Instead, the sprite should move around the screen at the same time as it says the instructions.

Test this out by clicking on the save block, then quickly clicking on the repeat loop.

To make both the say and the go to actions happen at the same time, drag out a when I receive event.

Click the drop-down arrow, choose new message, and add a message name you like.

This example calls the message catch me.

Snap this receive block above the repeat loop.

Drag out another when I receive block.

Place it above the say block, and choose your message name from the drop-down.

Both stacks of code are now waiting to receive the same queue or event.

That tells them it's time to act in the commercial.

To test the code, drag a broadcast block into the script area, and choose the message you just added from the drop-down list.

Test your code by clicking the broadcast block.

In this example, the event name catch me is broadcasted to all the sprites in the project.

The penguin is waiting to receive the event.

It immediately starts running all the code under any when I receive catch me blocks.

The penguin simultaneously runs the say blocks and bounces around the screen.

That looks great.

Next, add code for what happens if the user successfully clicks on the sprite.

Add a when sprite clicked event, and a save block to reveal what the user won.

Test the code by clicking the broadcast block again, then the sprite, if you can catch it.

That looks great.

To make the sprite stop moving when clicked, and also, to hide it before and after the event is called, add a stop other scripts and sprite block, and some show and hide blocks.

Try the code by clicking the broadcast block.


The sprite gives them instructions, moves around the screen, and reacts when clicked.

However, the most important step is still left for you to do.

If you don't add the broadcast block to the code you already built in another sprite, then none of this new code will ever run during the actual commercial.

This example will add the broadcast block to the Scratch Cat, but you should add it where you like for your project.

If you drag the broadcast block under the when flag clicked event, and set the broadcast block to the catch me event, for example, the penguin will display at the very beginning of the commercial.

You can even use the event more than once.

Adding in a catch me event near the end of the code will make the penguin reappear and say the instructions a second time.

Remember, your code will look different than the example you see here, but it's important that you add your new broadcast event somewhere in your other sprite's code.

Otherwise, the new code you created will never run, and your users will never have a chance to catch your sprite.

Now it's your turn.

Add a new sprite, code the sprite to give instructions, move around the stage, and react when the user clicks on it.

Remember to add the broadcast block to another block stack, so that your new code is run during your commercial.

And the broadcast block also needs a matching when I receive broadcast block to run.

Choose an Add-On

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.

Buy Button

Add a button for buying your product.

Ask Your Audience

Ask your audience a question, and program a response.


  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!