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 displayinga 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 startfrom 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 sothe 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 youjust 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 codeunder 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 yourcommercial 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 shouldadd 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 stacksof code to be run at the same time.
These code stacks can be in multiple sprites, so you could have lots of sprites come onstageas 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, changescolor 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 thecode 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.
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.
Add a button for buying your product.
Ask Your Audience
Ask your audience a question, and program a response.