How to Make a Mouse Trail

Материал из Поле цифровой дидактики

A mouse trail is a trail of any shapes that follows the mouse pointer around the screen. They are usually used in projects for fun, decoration, and detail. Usually mouse trails use the Looks Blocks and/or Motion Blocks.

Common project types that can include mouse trails include parallaxes.


Important Blocks to Use

point towards (mouse-pointer v)

go to (mouse-pointer v)
distance to (mouse-pointer v)

Sprite Mouse Trails

Choosing a Sprite

Before you can start your mouse trail, you need to pick out a shape, even if it is just a simple colored circle. It can be anything, but it shouldn't be too big. You can find some good sprites in the sprite library.

If you want, you can give the sprite different costumes for more variety. This will make the mousetrail more colorful and creative. If this is done, make sure to include a script that tells the clones to change to a random costume.

Base Scripts

There are many ways to edit a mouse trail, but this is a basic template. You can make the sprites do whatever you want. To begin to make a mouse trail, start with this script. Шаблон:Note

when gf clicked
go to (mouse-pointer v)
forever
create clone of (myself v)
point towards (mouse-pointer v)
move (distance to (mouse-pointer v)) steps
wait (0.001) secs
end

when I start as a clone
point towards (mouse-pointer v)
repeat (10)
change [ghost v] effect by (10)
end
delete this clone

See Customizing for help on editing this script. A project with sprite mouse trails can be found here.

Pen Mouse Trails

The Pen blocks can be used to make mouse trails. To make a mouse trail drawn with pen, use these scripts: Шаблон:Note

when flag clicked
forever
erase all
wait (0.01) secs
end
when flag clicked
pen up
set pen color to [#FF0000]
hide
point in direction (90)
forever
go to (mouse-pointer v)
create clone of (myself v)
change pen color by (10)
end
when I start as a clone
set pen size to (10)
repeat until <touching (edge v)?>
pen up
move (10) steps
pen down
end
delete this clone

See Customizing for help on editing this script. Some of the dots might stay on the project until they touch a corner. A project with a pen mouse trail can be seen here.

Customizing

Try changing the values of colors, sizes, and ghost effects etc. Try using a pick random () to () block instead of numbers. Maybe try a turn cw (42) degrees somewhere in between, or use a change [color v] effect by (23) or choose other graphic effects or put in your own ideas.

Using the (() / ()) block will mostly smoothen the movement of the sprite.