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.

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

Next, program the sprite to spin.

Drag out a turn block, and place a repeat loop around it.

Click on 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 spin faster.

To make the sprite turn when touching the mouse pointer, use an if-than 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 ten steps block to your program under the forever loop.

Test it out.

The sprite runs to the edges 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 in the opposite direction making it bounce.

Now, shoppers can interact with the sprite and make it go crazy.

Now it's your turn.

Add a new sprite, code it to go crazy using repeat and turn blocks.

Code your sprite to turn if it is touching the mouse-pointer using the forever loop, an if-then statement, and touching blocks.

Program the sprite to move around and bounce if on the edge forever when the green flag is clicked.

Remember to test your code often, and ask your neighbor if you have a question.

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!