How to make a mouse frame in Scratch (2) - the mouse frame defines the character

hello, everyone, and welcome to the second lesson of the mouse frame series!

Let's stop talking nonsense and start directly

First of all, let’s review the past and learn something new. In the last tutorial, we discussed how to draw the mouse box. URL: draw mouse box

You said, what is the use of a mouse frame? Isn't it just to frame the character?

Well, for this lesson, we will learn to frame

First, draw a character:

(first shape)

Unchecked

This is the ↑↑↑ before selection

Next is selected:

(second shape)

selected state

These are two looks of a character

Then, let's code:

First, determine a few clones

Then, edit the clone

1. Setting

2. Select

Remember the variables from our last lesson?

Now it works,

judge

Then, determine whether the mouse frame is framed

Here, I drew a picture for you to understand better

Make a classification discussion to figure out the relationship between "and" and "or"

break it down

Finally connect with "and":

ok, fill it in

Then, create a variable, a private variable

It can then be detected with (1: checked, 2: unchecked)

ok, that's it

Of course, it can be canceled after selection

For better performance, we don't use this:

First, add the extension:

white cat

There is a code in it (if there is no white cat extension, use the "mouse pressed?" block in the detection):

Prevent pressing the right button. Of course, if you set the right button to cancel, then you can change it to "whether the right button of the mouse is pressed".

OK, the full code is here:

Of course, mouse clicks are also available!

ok, that's it

Guess you like

Origin blog.csdn.net/leyang0910/article/details/132001066