Skip to content

Please update your browser

Your browser version is not supported by this site. CS First may not work properly. Learn more

4. Creating Stamps

Transcript

In this screencast you will program the clone to follow the mouse when clicked, and to stamp itself.

Right now, the clone's actions match the sprites.

If you want to program the clone to do something else, you need to use an event.

Drag the when I start as a clone event from the control menu into the blocks area.

To make the clone follow the mouse pointer, drag out the go to mouse pointer block.

Just like the spray paint sprite on day five, however, the clone should keep following the mouse pointer, not just go to it once.

To make the clone keep performing an action, use a loop.

On day two, to animate the sprite forever, you used a forever loop.

On day three you animated the mouse a certain number of times.

So you used a repeat loop.

Today you don't know how many times you want the sprite to follow the mouse pointer, but you do know it should keep doing so until the mouse is clicked and not after.

Luckily, there is a loop for that, repeat until.

Place a repeat until loop around the go to mouse pointer block.

Like an if block, a repeat until block has a space for a condition that will stop the loop from running.

In this case, the mouse down block is the condition.

From the sensing menu, place a mouse down block inside the repeat until block.

Make sure the repeat until block is under the when I start as a clone block so only the clone will move.

Test the code.

When you clicked the sprite, a clone is created.

The clone then enters the repeat until loop and follows the mouse pointer until the mouse is clicked.

Great! Keeping track of lots of clones can slow down your program and the project only needs this clone to leave a stamp of itself on the stage.

To leave an image of the clone, place a stamp block after the repeat until loop.

Finally, place a delete this clone block after the stamp block so your computer knows it doesn't have to keep track of the clone anymore.

Test the code.

When you click the sprite in the toolbox it should create a clone.

When that clone is created it should follow the mouse pointer until the mouse is clicked.

At that point it should leave a stamp of itself.

It does!

Now it's your turn.

Program the clone to execute code with the when I start as a clone block.

Make the clone follow the mouse pointer until it is clicked using a repeat until loop, a go to mouse pointer block, and a mouse down condition.

Make the sprite stamp after the clone stamps, delete this clone and add some wait time before the loop runs.

arrow_backward Back
Next arrow_forward
Instructions
  1. Make the clone do something different from the building block sprite.
  2. Make the clone follow the mouse pointer until the mouse button is pressed down again.
  3. Make the sprite stamp.
  4. Keep the program from getting bogged down.