[Scratch] programming? Teach you a lesson! In fact, we do not have a learning how to use the code.

[Scratch] programming?  Teach you a lesson!  In fact, we do not have a learning how to use the code.

199 articles


Laoding courses

 

In many tutorials inside, we all like to block out one by one about its function.

The advantage of this is that you can put each of the code function module said very clearly. But the most annoying problem has cropped up ......

 

For example, when you learn English, learn grammar, vocabulary or learn?

 

Certainly the grammar ah ...... because the syntax is basically the language rules, the rules are limited. And, in many cases, the rules can be reassembled according to their own requirements. The words do? Endless ...... So, the level of English proficiency, in a sense, the vocabulary itself is a good reference standard.

 

If the time learning English, vocabulary back light, first, remember, second, not to use, then the face of the vast citing ...... how can you learn it?

 

So, we need to understand the perspective of learning these things.

So again, we still method from a programming process, as beginning the actual operation of it!

 

The course will be integrated into many applications and knowledge within the curriculum to tell Oh!

 

Doomed, this is not a manual-style tutorials .

 


 

Although Scratch there are so many types of modules, in fact, in the final analysis, only two kinds.

 

The first are long like this, like one card. They are responsible for a particular process or program execution determination execution cycle.

 

[Scratch] programming?  Teach you a lesson!  In fact, we do not have a learning how to use the code.

 

No matter what color they were, in fact, we can understand, they all belong to the same kind - are in a heap.

 

These first whether the code is doing, anyway, you just put random stack these guys together, we can make a program.

 

[Scratch] programming?  Teach you a lesson!  In fact, we do not have a learning how to use the code.

 

And the program will be based on the sequence from top to bottom, beginning execution.

 

The second is oval and hexagon of.

 

[Scratch] programming?  Teach you a lesson!  In fact, we do not have a learning how to use the code.

 

These we think they can be a "condition" code.

 

专管数据条件、逻辑条件(布尔运算)、处理数据等等,反正千变万化,可以有很多很多种,十分考验运用能力。它们给流程模块和输出模块,带来了各种各样的“条件要求”。当然,这些条件都可以由你自己来设置。

 


 

与EV3不同,Scratch的编程工具,开发的更为“详细”。

 

比如,关于启动的流程模块,也就是“事件”下面所对应的各种代码块。

 

[Scratch] programming?  Teach you a lesson!  In fact, we do not have a learning how to use the code.

 

这些模块一般都是用来启动某一套程序的。你可以设定各种各样的启动条件。

 

其他的都很好理解,比如当小旗帜被点击,当空格(也就是电脑键盘上的空格)被点击,它们都是用来触发程序启动的“条件”。

 

诶,对了,这里我们看到了几个关键词

 

[Scratch] programming?  Teach you a lesson!  In fact, we do not have a learning how to use the code.

 

角色、背景、广播,它们是什么?请看下面这个全景图。

 

[Scratch] programming?  Teach you a lesson!  In fact, we do not have a learning how to use the code.

 

跟Mindstorms相比,Scratch多了一个“角色”的感念。同时也多了一个“背景”的概念。

 

简单说,这两种东西,都是“对象”

你编程对谁编?

当然是对“对象”来编程啦。

 

对象可以是“角色”,也可以是“背景”。区别是,角色可以移动来移动去,而背景就是整个背景图案啦。

 

点击上图右下角的两个按钮,大家可以自己添加角色和背景。这个很简单,没什么特别的地方,尝试一下马上就明白了。

 

当你需要对一个添加完的角色或者背景进行编程或者修改的时候,就要去选中对应的那个对象。

 

[Scratch] programming?  Teach you a lesson!  In fact, we do not have a learning how to use the code.

 

然后你就可以根据上图做这些事情。

 

了解了上面这些内容后,大家就明白了。

在Scratch里面,我们的编程可以明确的针对每一个被添加上的角色和背景来进行操作!

 

简单说,就是,让谁干嘛就干嘛。在一个程序里,每个对象的分工都可能是不同的,而我们,只要明确的告诉每个对象,做些什么,就ok啦!

 


 

而你可以看到,上文说到的这两类代码都是配合着使用的。

 

比如,首先,我们在程序的一开始,需要放一个启动模块。(什么操作触发程序启动)

 

[Scratch] programming?  Teach you a lesson!  In fact, we do not have a learning how to use the code.

 

我们当然,可以很简单的放上另一个卡片,来控制这只Scratch猫。这只需要放上一个代码即可。可以手动输入半圆内的数字,来控制一下这只猫。

 

但这毕竟是手动输入呀,程序不是应该可以根据一些情况自己计算距离的么?

 

[Scratch] programming?  Teach you a lesson!  In fact, we do not have a learning how to use the code.

那么我们稍微提一个复杂一点的要求好了,这样比较容易帮助小朋友理解问题。

要求:当绿色旗帜被按下后,让小猫,以再次按下鼠标之间的时间为条件,移动到坐标(100,0)的位置。

问题其实也挺简单的。我们可以看得出来,最终呈现的效果一定是间隔时间越短,猫移动的越快,而间隔时间越长,猫移动的越慢。对么?

这个时候,我们就需要使用到这些“数据条件”代码的配合啦。

首先,在程序一开始,把我们需要用到的计时器和猫的位置归零。

[Scratch] programming?  Teach you a lesson!  In fact, we do not have a learning how to use the code.

 

这是一个习惯问题,在我们使用任何数据模块的时候,程序一开始,尽量要养成归零或者完成初始值设置的习惯。这样方便我们日后检查一些程序的问题,同时也容易帮助我们找到问题,这个在以后的课程中,我们会经常提到。

 

第二步,把题目中要求的两个动作给放上去。

1、等待鼠标点击

2、把猫移动位置给设定好

 

[Scratch] programming?  Teach you a lesson!  In fact, we do not have a learning how to use the code.

 

我们可以看到上图的两个位置,是可以放上两种形状的代码的!

 

[Scratch] programming?  Teach you a lesson!  In fact, we do not have a learning how to use the code.

 

这种形状,我们叫做“布尔运算”代码。不作过多的解释了,大家简单理解为,这就是一种逻辑判断就可以了。

 

逻辑嘛,就是“是”或者“不是”;“包含”或者“不包含”;“成立”或者“不成立”……

 

Anyway, it is a second election one, the radio conditions. It is also a value in itself, illogical when its value is 0; and when the logical value of which is 1.

 

It can also be used directly as data, but its data changes, only 0 and 1 two kinds.

 

[Scratch] programming?  Teach you a lesson!  In fact, we do not have a learning how to use the code.

 

And these figure, is "Data calculation." Code. They more than likely it slightly. You can operations, addition, subtraction, and even more advanced math. They ultimately represent the various values.

 

We are subject to two kinds of data required, the corresponding drag "operation code is" position, this procedure is complete it!

 

[Scratch] programming?  Teach you a lesson!  In fact, we do not have a learning how to use the code.

 

Is not very simple, hands-on try it!

Of course, the understanding of the content, you can make some kinds of small attempts.

 

Is not difficult to learn, it is not difficult to understand, but familiar, still need some time to drop!

Guess you like

Origin www.cnblogs.com/scratch3/p/10936617.html