Please update your browser
Your browser version is not supported by this site. CS First may not work properly. Learn more.
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 sprite's.
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 box area.
Add a "wait" block and set it to a very short time.
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 continue 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 mouth
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
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.
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 any more.
When you click the sprite in the tool box,
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.
Now it's your turn.
Program the clone to execute code
with a "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.