Getting the mouse position
There are many times where it may be useful to have the mouse position in the program. Perhaps you want an object to follow the mouse, perhaps you want something to happen based on the mouse position, such as a graphic effect.
Getting ready
In this recipe, we're going to create a program that makes our sprite change its graphic effects based on the mouse position.
Start off by creating a new file and importing a new sprite. In our case, we've imported Monkey1 with the white background.
How to do it...
We're going to apply two effects, one based on the mouse's horizontal direction, another based on the mouse's vertical direction. Follow along with these steps:
Drag over a green flag block (from Events).
Drag over a forever loop (from Control).
Inside the forever loop, drop a set () effect to () block from the Looks category and make the effect that we work with whirl.
Also into the forever loop, drop a set () effect to () block as well, this time make the effect color. We...