3. Performance Time
In this video, you'll demonstrate how the fitness gadget improves athletic performance.
First, introduce the performance test that you're about to complete with a say block.
This example says, let's take the SportsWatch9000 for a run.
Next, use motion blocks to move the spread around the stage.
This example will use glide blocks from the motion menu.
Every spot on the stage has an X, left and and right, and Y, up and down position.
To set the X and Y positions in the glide block, drag the sprite to a location on the stage.
The glide block will automatically update the values based on the sprite's position.
In this example, the sprite will run a few spots on the stage.
Drag the sprite to where it should go, then place the glide block below the save block in the scripts area.
Once you place a glide block in the scripts area, the numbers in that block won't change unless you type new ones.
Test the code by clicking on the glide block.
Wait, the sprite didn't move.
Move the sprite to its starting position.
The X and Y position and the go to X, Y block will update to match its location.
From the motion menu, place the go to X, Y block above the save block.
Click on the code again.
The sprite starts at one spot, then glides to another.
Next, repeat the steps to make the sprite run to several locations on the stage.
Move the sprite to a new location, drag out a glide block and test.
To make your sprite run faster or slower, change the seconds value in the glide blocks.
The sprite runs around the desert, but you can make your sprite do anything by selecting a different backdrop and using glide blocks and repeat loops.
In this example, the sprite gets ready for the race by jumping up and down.
In this example, the sprite takes a quick swim through the ocean waters.
In this example, the sprite heads over to the mountains and skis down the slopes.
Now that your sprite has demoed the product, use save blocks to describe how the fitness gadget improved the athlete's performance.
This athlete says, thanks to the SportsWatch9000, I'm now the world's fastest android.
To make the sprite start the product demo at the right time in your commercial, use broadcast and wait and when I receive blocks.
A broadcast block broadcasts, or sends a message, to another part of the program.
A when I receive event sets up the other part of the program to get the message and run the code to make something happen.
In this case, that's making the sprite run all over the place.
Drag out the broadcast and wait block and snap it below the main stack.
Click on the drop down.
There's no message for running, so click on new message to create one.
This message needs a name.
It will broadcast when the sprite should start running.
Name it something descriptive like product demo.
Next, program the sprite to receive the message.
From the events menu, drag out the when I receive block and snap it above the code stack you just created.
To make sure the sprite is responding to the right message, check that product demo is selected in the drop down menu.
When the sprite receives the product demo message, it should run the code and start running around.
Now the sprite does the introduction after it gets the message introduce product, then it runs around when it receives the product demo message.
The broadcast blocks simplify your code through modularization by breaking it down into subprograms.
A subprogram is a small stack of blocks that does one specific thing within a larger program.
This allows you to add different features to your commercial without making your code too long or complicated.
All right, here's the game plan.
First, drag the sprite to where you want it to move, then add a glide block.
Do this as many times as you like.
Add a go to block to tell the sprite where to start on the stage, add broadcast and when I receive message blocks so your code will run just after the introduction.
- Drag the sprite to where you want it to move, then add a "glide" block. Do this as many times as you like.
- Add a "go to" block to tell the sprite where to start on the stage.
- Demo the sprite's athletic performance using "glide" blocks and "repeat" loops
- Add "broadcast and wait" and "when I receive message" blocks, so your code will run just after the introduction.
Sign in to save your project and track your progress.