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

In this add-on, you’ll program your stylist tool to create a colorful trail as it moves around the screen. Make sure the stylist sprite is highlighted.

The colorful trail will be created by clones, or copies of the original sprite. To make clones, add a “create clone of myself” block under the “go to mouse-pointer block.”

Try it out. The sprite creates a trail as it moves across the screen.

On the stage, the trail left by the accessory remains on the screen and covers up the background that is being styled. To fix this, drag out “when I start as a clone” and “delete this clone” blocks, and snap them together. The “When I start as a clone” block is an “event” block. The shape on the top gives this away. It performs the actions you code under it.

Click the green flag to run the code. The stylist tool does not show a trail because the code tells the sprite to delete the clone as soon as it is created. Fix this by adding a “wait” block between the two blocks. Test the code by clicking the green flag again.

Now the clone trail deletes after 1 second. Tinker with the value in the “wait” block so the trail that doesn’t cover the screen for too long.

Once you find a value that you like, code the trail to be multi-colored. Remember that the “change color effect by” block changes the color of your sprite.

From the looks menu, drag out a “change color effect by” block into the scripts area, and place it in your new code stack. To repeat this color change, drag a “repeat” loop around your “wait” and “change color effect by” blocks. Click the green flag to test your code. Once you click the green flag and the stylist tool, the accessory follows the mouse-pointer and creates a clones of itself. However, the trail is lasting longer than before! That’s because the program is changing the color of the accessory 10 times every 0.2 seconds. To fix that, change the value in the “wait” block to a smaller number.

Every time the clone is created, it changes its color effect, waits .02 seconds before changing again 10 times, then deletes itself. This creates a fading, color-changing trail.

Test the code again. Click the flag, move the mouse pointer, and click space to stamp the accessory. Oh no, it stamps the entire clone trail. To make the sprite stamp only itself and not the clone trail, add a conditional statement. From the control menu, add a "if-then" block after the "create clone of myself" block. From the sensing menu, add a "space key pressed" block to the if portion of the "if-then" block. From the scripts area, drag the "stamp" block to the then portion of the block. The "when space key pressed" block is no longer needed, so delete it by right clicking the block and selecting delete. Test again. Click the flag, move the mouse pointer, and click space. Great! Now, the sprite stamps only once, instead of stamping the entire clone trail. Now, it’s your turn!

Program the accessory sprite to leave behind a colorful trail of clones.

Program the sprite to stamp only a single copy of itself, instead of stamping the clone trail.

Choose an Add-On
Refashion
Create a new accessory for your project.
Flashy Mouse
Program your stylist tool create a colorful trail as it moves around the screen.
Stylist Game
Make your stylist tool into a game that lets the user race against the timer to style the model.
Animate Model
Program your model to animate when you place an accessory on it.
Stylist Critique
Create a stylist critic and program it to give feedback for the stylist project.
Sound (Challenge)
Add sound to your project.
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!