In this video, you will change
your sprite's looks depending upon the position
of the mouse pointer.
You will use key press events and the variable, mouse x.
In today's project, you used the change-effect-by block
to make Tera change colors.
To change other effects
go to the Looks menu
and add another change-effect-by block.
Notice you can also change effects
other than the color with this block.
If you choose fisheye, for example,
Tera's face seems to swell.
If you choose whirl, Tera turns into a spiral.
This example will use the whirl effect,
but you can choose any cool effect you like
for your art project.
To better control when effects change,
add a when-key-pressed event block
and change the drop-down menu to a keyboard letter like C.
Connect a new change-effect-by block
to the when-key-pressed block.
Now, when you press the C key, Tera turns in a spiral.
However, the effect never stops,
and the sprite never returns to its original state.
How could you get Tera to return to its original form
without starting the project over?
Add another key-press-event and change-effect-by block.
Then change the value in the block to a negative number,
just like you did in the core project.
To return Tera to its original state,
add a key-press-event and the clear-graphic-effects block
from the Looks menu.
To make Tera's color change a bit more random,
add the variable mouse x from the Sensing menu
to the change-effect-by block.
This variable is determined by the mouse's position
on the screen.
If you look at the bottom right of the stage,
you will see x- and y-coordinates.
When you move the mouse from right
to left across the screen,
these numbers change from positive to negative
and are recorded in the mouse x variable.
You can use mouse x to return your sprite
to its original form after the effect.
In this example, once the program starts
and the C key is pressed, Tera whirls.
When the mouse moves, Tera changes effects,
depending on the position of the mouse.
Test this out in your project,
and experiment with different effects,
variables, and key-presses.
Now it's your turn.
Experiment with different effects
in the change-effect-by block,
and choose an effect you like for your project.
Add a key-press-event to control when the effect changes.
Try one of the three options that will make the effect
stop and return the sprite to its original state.
Change the the character sprite’s looks based on the mouse pointer’s position.
Add background music to the project.
Use arrow keys to make Tera grow and shrink on command.
Make the sprite move using the keyboard instead of the mouse.
Create another sprite that can collide with your character sprite.
Add your own costume to your sprite.
Sign in to track your progress and earn badges