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 itand 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 looparound it. Click the block stack to try it out.
Tinker with the values inside the repeat loop and the turn block. Putting a higher numberin 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 looparound the code. Click the block stack to test it out!
Awesome! It works. Make sure to add a “When flag clicked” eventto run this code when the flag is clicked. To make the sprite randomly move around thescreen, 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 disappearsFix this by adding an “if on edge, bounce” block. This block checksto see if the sprite is touching the edge of the screen. If it is, it points it in theopposite direction, making it bounce. Now, shoppers can interact with the helicopterand make it go crazy!
Choose an Add-On
Create a sprite that changes colors when the mouse hovers over it.
Create a sprite that will perform different actions in response to its surroundings.
Code a hidden surprise in your display window.
Code your sprite to go crazy when the mouse-pointer touches it.