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 create a sprite that changes colors when the mouse hovers over it, making it 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 project will 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” block from 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 touching the 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 in the “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 place it 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 effect should 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 program starts! This is your chance to share your project with others and tell them how it works. Write clear instructions so any Scratch user can play 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” sensing block, a forever loop, and a “change color effect by” block to make the sprite change colors when the mouse pointer touches it. Test your code, and ask a neighbor if you need any help.

Choose an Add-On
Color Change
Create a sprite that changes colors when the mouse hovers over it.
Drift
Create a sprite that will perform different actions in response to its surroundings.
Hidden Surprise
Code a hidden surprise in your display window.
Go Crazy
Code your sprite to go crazy when the mouse-pointer touches it.
Talk about it (Challenge)
Add talking sprites in your program.
Shooting Sprites (Challenge)
Make a sprite shoot across the stage.
arrow_backward Back
Next arrow_forward
Instructions
  1. Choose an Add-On, and click "watch" to learn how to build it.
  2. Once you finish one Add-On, try another one below the video!