arrow_back Go Crazy
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!