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 sprite around the stage. This example will use “glide” blocks from the motion menu. Every spot on the stage has an x (left 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 stage. The “glide” block will automatically update its values based on the sprite’s position. In this example, the sprite will run to a few spots on the stage. Drag the sprite to where it should go, then place the “glide” block below the “say” block in the scripts area.
Once you place the “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 in the “go to x y” block will update to match this location. From the “motion” menu, place the “go to x y” block above the “say” block. Click on the code again. The sprite starts in one spot, then glides to another.
Next, repeat these 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.
Nice! To make your sprite run faster or slower, change the seconds value in the “glide” blocks. Sweet.
This 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.
Check out these examples. This sprite get’s ready for the race by jumping up and down. This 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 “say” blocks to describe how the fitness gadget improved the athlete’s performance.
This athlete says: ““Thanks to the SportsWatch 9000” “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 a program. A “when I receive” event sets up the other part of the program to get the message and run code that makes 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 dropdown. There’s no message for running, so click on “new message” to create one.
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 dropdown menu. When the sprite receives the product demo message, it should run the code and start running around. Great. 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 sub programs. 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 code too long or complicated.
Here’s the game plan: 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.
- Glisse le lutin là où tu veux qu’il aille, puis ajoute un bloc "Glisser". Fais-le autant de fois que tu veux.
- Ajoute un bloc "Aller à" pour dire au lutin où démarrer sur la scène.
- Teste la performance athlétique du lutin à l’aide des blocs "Glisser" et des boucles "Répéter".
- Ajoute des blocs "Envoyer à tous et attendre" et "Quand je reçois le message" afin que ton code s'exécute juste après l'introduction.