Skip to content

Please update your browser

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

arrow_back Sprite Trail

Transcript

In this add on you will create a color changing trail that follows the yellow x sprite across the screen.

To achieve this effect you will program the sprite to make clones of itself and stay on the screen for a short period of time.

Select the yellow x sprite.

You will create a separate stack of blocks that controls the movement and cloning of the sprite.

Drag the go to mouse pointer block out of the block stack.

This sprite still needs to follow the mouse pointer, so drag out a forever loop from the control menu, and place it around the go to mouse pointer block.

This sprite should also follow the mouse pointer when the project starts, or when the green flag is clicked.

Drag out a when green flag is clicked block from the events menu and place it at the very top of your new block stack.

Test your code.

(piano notes playing)

When the green flag is clicked, the sprite should still follow the mouse pointer.

To create a clone of this sprite, drag out a create clone of myself block from the control menu and place it inside the forever loop of the new code stack.

Test the code again.

(piano notes playing)

Now, the sprite follows the mouse pointer and leaves a trail of clones behind it.

This is a pretty cool effect, but it would be nice if the trail disappeared after a brief period of time.

To make the clones disappear, drag out a when I start as a a clone block from the control menu.

Any code you add to this event block will tell the clone exactly what to do.

To make the clone disappear, drag out a delete this clone block and connect it to when I start as a clone block.

Test the code now.

(piano notes playing)

Ah, the clone disappears completely.

(piano notes playing)

You need to tell the program to wait a little bit before deleting.

Drag out a wait one second block and place it before the delete this clone block, and test the code again.

(piano notes playing)

Great.

Now the trail follows our sprite, but doesn't stay forever.

The wait time determines how long the sprite's trail will be.

Tinker with the values of the wait block until you find a trail effect that you actually like.

One more thing.

You can always add a color changing effect to the sprite's trail.

From the looks menu, drag out a change color effect by 25 block and place it inside the forever loop under the create a clone of myself block.

Tinker with the value of the color effect until you find something you like.

And don't forget to test the code, often.

(piano notes playing)

Now it's your turn.

Using a when green flag clicked event, a forever loop, the go to mouse pointer block from your original block stack, and a create clone of myself block, create the code to make the sprite follow the mouse pointer and create a clone of itself forever when the program starts.

Use the when I start as a clone, wait, and delete this clone blocks to make the sprite trail disappear after a short time.

And lastly, add a change color effect block to make the sprite trail change colors.

Choose an Add-On
Change Instrument and Tempo
Change instruments and tempo in your musical art piece when the yellow X sprite touches different colors.
Make it Melodic with a Chord
Make your project play chords, not just individual notes.
Easter Egg Surprise
Add a surprise color to your art piece that plays an unexpected sound when touched.
Sprite Trail
Add a graphic effect that makes the yellow X sprite leave a color-changing trail across the screen.
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!