Skip to content

Please update your browser

Your browser version is not supported by this site. CS First may not work properly. Learn more

Transcript

This add-on will walk you through how to code your sprite to spin when the mouse pointer touches it.

To start, click on “choose new sprite from library” to add a new sprite.

This project uses the Helicopter so shoppers can interact with it and make it go crazy in the window display, but you can pick any sprite you’d like.

Use the shrink tool to make your sprite smaller on the stage.

Next, program the sprite to spin. Drag out a “turn” block, and place a repeat loop around it. Click the block stack to try it out.

Tinker with the values inside the repeat loop and the turn block. Putting a higher number in the turn block, like 120, will make your sprite turn faster.

To make the helicopter turn when touching the mouse-pointer, use an “if-then” statement.

Place this around the repeat loop, and add a “touching mouse-pointer” sensing block.

For this code stack to keep running and checking for the mouse-pointer, add a forever loop around the code. Click the block stack to test it out!

Awesome! It works. Make sure to add a “When flag clicked” event to run this code when the flag is clicked. To make the sprite randomly move around the screen, add a “move 10 steps” block to your program under the forever loop.

Test it out. The helicopter runs to the edge of the screen and disappears Fix this by adding an “if on edge, bounce” block. This block checks to see if the sprite is touching the edge of the screen. If it is, it points it in the opposite direction, making it bounce. Now, shoppers can interact with the helicopter and make it go crazy!

Scegli un’estensione
Cambia il colore
Crea uno sprite che cambia colore quando gli passa sopra il mouse.
Orientamento
Crea uno sprite che esegua azioni differenti in risposta all'ambiente circostante.
La sorpresa nascosta
Crea una sorpresa nascosta nella tua vetrina
Scatenati
Codifica il tuo sprite in modo che impazzisca quando viene toccato dal puntatore del mouse.
Parlane (Sfida)
Aggiungi degli sprite parlanti al vostro programma.
Sprite scoppiettanti (Sfida)
Fai schizzare uno sprite attraverso il palco.
arrow_backward Indietro
Avanti arrow_forward
Istruzioni
Scegli un componente aggiuntivo sottostante che desideri costruire.