In this add-on, you’ll program the sprite to dance while wearing the fitness gadget.
First, click the android sprite, select the "looks" menu, and drag out a “change coloreffect" block. This block changes the graphic effect on a sprite. Click the dropdown menu,and select “whirl effect." Click on it to try it out! The sprite dances to the right.
If you keep clicking this block, the sprite continues "dancing" to the right. Click thestop button to reset the sprite. To make the sprite dance to the left, dragout another “change whirl effect” block. This time, change its value to negative twentyfive. Try it out. That’s not bad. The sprite dances to the left.
A dance is more fun if you put all the moves together. To do this, snap both “changewhirl effect” blocks together. The block stack should now make the sprite dance tothe right, then to the left. Try it out! Hmm, nothing happens because there's no gap orwait time between the blocks. The sprite dances so fast that you can’t see it.
To slow it down, drag out two “wait” blocks from the control menu. Snap one after eachof the the "change effect" blocks. Now, when you click on the block stack, you can actuallysee the sprite do its dance.
To change how fast the dancer moves, change the value in the “wait” block. Lower valueswill make the sprite move faster, and higher values will make it move slower. Try 0.2 seconds,or plug in different values until you find one that you like.
Cool. The sprite dances, but only to the right, instead of to the right and then to the leftlike expected. That’s because the “change effect by 25” block makes the sprite danceto the right, and the second “change effect by negative 25” block makes the sprite goback to normal. Add a “change whirl effect by negative 25” block to make the spritedance to the left. Add a “wait” block, then a “change whirl effect by 25” blockto make the sprite go back to normal. Add another “wait” block. Try it out. Great!
Now the sprite dances to the right, then to the left.
Next, add a “repeat” block from the control menu around the whole stack to repeat thedance moves a few times. In this example, the sprite will do the dance 6 times, butyou can make the sprite dance as many times as you want. Test this code by clicking on it.
That’s pretty awesome. The sprite dances!
To make the sprite dance 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 anotherpart of a program. A “when I receive” event sets up that other part of the programto get the message and run the code that makes something happen. In this case, that’s makingthe sprite dance. Drag out a “broadcast and wait” block,and place it in the main code stack when you want the sprite to do its dance. Click onthe dropdown. There’s no message for dancing, so click on “new message” to create one.
This message needs a name. It will broadcast when the sprite should dance, so name it somethingdescriptive, like “happy dance.” Next, the sprite needs to receive the message.
From the “events” menu, drag out the “when I receive” block, and snap it above thecode stack you just created. To make sure the sprite is responding to the right message,check that “happy dance” is selected in the dropdown menu. When the sprite receivesthe dancing message, it should run the code you created and start dancing.
Great. Now the sprite does the introduction after it gets the message, “introduce product.”
Then, it dances when it receives the “happy dance ”message.
Pretty cool, right? Here's the game plan:Make the sprite dance using the “change effect by,” “wait,” and “repeat”blocks. Send a message from the main code stack tomake the sprite dance using “broadcast” and “when I receive message” blocks.
Danza della felicità
Fai ballare lo sprite.
Cambio di scena
Sposta l'Android da un paesaggio all'altro per vedere come reagisce il gadget.
Aggiungi effetti climatici per dimostrare quanto è resistente il gadget.
Decidi se comprare
Chiedi allo spettatore di comprare l'oggetto.
Aggiungi al progetto altri sprite e falli interagire con l'atleta.
Il preparatore atletico
Ordina allo sprite di mostrare il battito e di parlare della sua frequenza cardiaca.