- Scratch Cookbook
- Brandon Milonovich
- 928字
- 2021-08-13 16:40:18
Other fun graphic effects
Now that we have a lot of the other story-creating features, we can have a little fun changing graphics in our story! You might have already taken a look and played around with some of the Looks blocks we haven't really talked about yet. This is where we will formally look at a few more of these.
Getting ready
Here in this recipe, we're going to focus on changing the color effect. Later, we'll also see a few other things you can do with the appearance of sprites. Our time will be spent adding the following three blocks to what we have so far:
The first of these will help us give our sprites some fun effects while the other two will be used to reset those effects back to our starting place.
How to do it...
Let's get started:
- Let's begin by making sure that everything is reset at the start of the program, even though we know nothing has been changed yet. This will make sure we don't forget to have our graphic effects reset later.
Note
These graphic effects are sprite specific, meaning you need to reset them for each sprite you plan on —eventually changing the graphics for. We're only going to change Monkey Mike here, but you may wish to change more.
- Ensure that you have the script area for Monkey Mike open.
- Drag over a green -flag block.
- Also, drag a clear graphic effects block. We can now feel safe and know that each time our program runs, any graphic effects we've added along the way will be set back to normal.
Tip
You may not want to use the all-in-one block we just used. If you only change the color, use the second block that we mentioned here to only set the color effect back to 0. You can do this with any of the other graphic effects that are available too!
- Next, we are going to delve into the realm of changing the color of a sprite. We don't have a way to merely select a specific color to change our sprite to. Instead, we change the value of the color effect.
- Returning to our previous project, we'll make it so that Monkey Mike changes color when he is clicked. Drag over the when this sprite clicked block from the Events menu.
- Returning to the Looks block menu, drag and connect the change color effect by block to the top hat block you just added.
- Depending on how extreme you want to make this change appear, adjust the number.
Note
Notice that you can adjust the number in the change effect by block by either a positive value or a negative value. A negative value will reverse any positive -value effect you've already applied. Play around with the numbers to see what happens!
- You should now run your program and click on Monkey Mike several times to see the color effect change.
How it works...
In the background when you change the color effect, there are 200 possible color schemes available. This means if you input a value higher than 200, the actual color that will be displayed would be the equivalent of the number modulus 200. For example, if you input a color effect of 300, you will observe the same effect as you would get when you put in 100. Another example would be 450; this would be the same effect as 50.
There's more...
You may be interested in having more than one effect in your program. The good news is that not a whole lot changes beyond what we've just done!
Drag over an additional change effect by block to the script we've already been working on in this recipe.
Clicking on the drop-down arrow, as is shown in the previous screenshot, gives us all the other graphic effects that Scratch has included! Here is a brief description of what each does. Each of these also has a screenshot (with an effect value of 50 applied) as a reference to what it will do to your sprite.
Fisheye
You might recognize the fisheye effect from looking into a fish bowl at some point in your life. This effect makes the center of the image look distorted and somewhat rounded.
Whirl
Whirl adds a spiraling effect to your sprite. The higher the value, the more intense the spiral.
Pixelate
You've probably seen the pixelate effect before when you've zoomed in really close into a digital image. Images are made up of what are called pixels (small squares of color). The more pixels you fit into a small space, the sharper the image.
Mosaic
A mosaic image is made up of many images put together. This effect splits your image into a series of small copies of that image.
Brightness
This effect simply changes the brightness of your sprite. After a certain point, the brightness won't do much to your sprite.
Ghost
If you're looking for a good way to make it look like your sprite is disappearing, this is the effect for you! As you increase the value of this effect, your sprite will become more and more transparent until it eventually disappears.
Play around with these color effects. Depending on the story you are trying to tell, these can be really handy in giving your story some life.
See also
- If you'd like to see more on how you can use different color effects, they'll come up again, particularly in the Graphic effects to backgrounds recipe in Chapter 3, Adding Animation