arrow_back Changing Scene
In this add-on, you will make the sprite move through several backdrops to demonstrate that the fitness gadget can work in many different environments.
Begin by adding several backdrops. To do this, click the stage, open the “Backdrops” tab, and click “choose backdrop from library.” Click the backdrop you want to add, then click “OK.” Repeat this until you have about 3 new backdrops.
Next, program the android sprite to glide from one backdrop to the next. Select the android sprite, then open the “scripts” tab. Click the “motion” menu.
Drag the android to the right edge of the stage. When you let go of the mouse, the values in the “glide” block update to reflect the sprite’s current position. Drag out the “glide” block. Move the android sprite back to its starting point, then click the glide block to test it out. Cool! The android glides to that spot.
To create the illusion that the android is traveling through different environments, add code to switch the backdrop and reset the android back to the left side. Open the “looks” menu, and add a “switch backdrop” block to the stack. Change the dropdown menu to “next backdrop.” Then, drag the sprite to the left edge of the stage, and add a “go to” block from the “motion” menu to the stack.
Click this stack to test it out.
Cool! It looks like the android travels to a new place.
Every time the stack is clicked, the android goes somewhere different.
Add a “repeat” loop around this stack to make this animation happen over and over again without having to click the stack multiple times. Click it to test it out.
Tinker with the value in the “glide” block to make the android move faster or slower.
Change the value in the “repeat” loop to match the number of backdrops you added, so that the android visits each location once. Test your code often when tinkering.
Right now, this animation ends awkwardly with the android off the left edge of the stage.
Add some code to make the android end in a more natural spot. This example uses two “glide” blocks to make the android move left, and then up. What you do is up to you!
Incorporate this animation into your commercial by adding a “when I receive” block to the top of the stack. Use a descriptive message, like “change scene.” Then, add at least one “broadcast and wait” block to the “when flag clicked” stack, in the place where the animation will happen.
Finish by adding a “say” block to the beginning of the “change scene” animation, so the viewer knows what the android’s about to do. This example says “It also works in different geographic areas!” Test the commercial by clicking the flag.
Here’s the Game Plan! Add some more backdrops.
Program the android sprite to look like it’s moving through different environments using the “glide,” “switch backdrop,” “go to,” and “repeat” blocks.
Complete the end of the animation using more “glide” blocks.
Add a “say” block to introduce this segment. Incorporate this animation into the commercial using a “broadcast and wait” block and a “when I receive” block.