This add-on will create a sprite that changes colors when the mouse hovers over it, makingit eye catching as window shoppers pass by your store front.
To start, click on “choose new sprite from library,” and add a new sprite. This projectwill use the Sun, but you can pick any sprite you’d like.
Next, make the sprite change colors. To start, drag a “change color effect by” blockfrom the looks menu into your scripts editor. Click the block to see what it does.
That looks cool, but in this add-on the sprite should change colors only when it is touchingthe mouse pointer. To make that happen, use an “if-then” statement and a “sensing”block. Place an “if-then” statement around the“change color effect by” block. This block stack now reads: “if something happens,change the color effect of this sprite.” Next add the condition that must be met inthe “if” portion of the “if-then” block in order for the sprite to change colors.
You want the sprite to change color when it touches the mouse, so add a “touching”block from the sensing menu. Drag out a “touching” block, and placeit inside the “if-then” block. From the options in the dropdown menu, choose “mouse-pointer.”
Now this reads: if the sun is being touched by the mouse-pointer, then the color effectshould change. Click on this block stack to test it.
Nothing happens! Your program needs to continuously check if the sprite is touching the mouse-pointer.
Add a Forever loop around the “if-then” block. Now test your code.
Great! Finally, add a “when green flag clicked” event block to run this code when your programstarts! This is your chance to share your projectwith others and tell them how it works. Write clear instructions so any Scratch user canplay with your project and make it work. Now it’s your turn:Add a new sprite, and create an if-then statement. Add a “touching mouse-pointer” sensingblock, a forever loop, and a “change color effect by” block to make the sprite changecolors when the mouse pointer touches it. Test your code, and ask a neighbor if youneed any help.
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.