复习:我们学到哪里了 5 分钟
- 故事是一排场景。每个场景都由一条消息开始。
broadcast [forest scene v] and wait会一直等到场景演完。普通的broadcast [forest scene v]不会等。when backdrop switches to [Forest v]让每个角色站到自己的位置。
快问快答
Wizard 运行 broadcast [hall scene v] and wait。Dragon 的台词放在 when backdrop switches to [Castle 3 v] 下面。Wizard 会等 Dragon 吗?
看答案
不会。broadcast and wait 只等消息开始的脚本。Dragon 的台词应该放在 when I receive [hall scene v] 下面。
今天的主题 3 分钟
- 故事地图告诉你故事在哪里分开。
- 上面写着字的按钮角色。
when this sprite clicked- 每条路一条消息。
- 选好一条路以后,把所有按钮都藏起来。
学习目标
上完这节课,你能够:
- 做一个按钮,被点击时发出一条消息。
- 把故事分成两条路,每条路有自己的背景。
- 读故事的人一选好,就把所有按钮藏起来。
学一学:会分岔的故事 28 分钟
画出故事地图
上节课,故事只有一条路。今天它在森林里分开。动手做之前,先把它画出来:
forest scene
|
fork
/ \
The Woods The Lake
| |
woods scene lake scene
| |
hall scene "Gobo plays with the fish."
| |
The end! The end!故事分开的地方叫岔路口(fork)。从那里出去的每一条路叫一条路(path)。地图上的每个方框都会变成一条消息。
做一个按钮
- Choose a Sprite(选择一个角色)→ Button2。就是宽的那个。
- 打开 Costumes(造型)标签。
- 选 T(Text,文字)工具。在按钮上点一下,输入 The Woods。
- 把角色改名为 Woods button。
- 右键点它,选 duplicate(复制)。把字改成 The Lake,名字改成 Lake button。
讲故事的人在岔路口停下
Wizard 的绿旗脚本变短了。它先讲第一个场景,然后显示岔路口:
when flag clicked
switch backdrop to [Forest v]
broadcast [forest scene v] and wait
broadcast [fork v]
一个可以点的按钮
每个按钮一开始都藏起来。到了岔路口才显示。点它,它就发出自己的消息。
- 在角色列表里点 Woods button。
- 打开 Events(事件)。
- 拖出
when this sprite clicked。 - 加上
broadcast [go woods v]。用 New message(新消息)做出这条消息。
when flag clicked
hide
when I receive [fork v]
show
when this sprite clicked
broadcast [go woods v]
读故事的人在选的时候,Gobo 在想:
when I receive [fork v]
think [The woods or the lake?]
每条路一条消息
然后 Wizard 继续讲故事。收到哪条消息,他就从哪里开始:
when I receive [go woods v]
switch backdrop to [Woods v]
broadcast [woods scene v] and wait
switch backdrop to [Castle 3 v]
broadcast [hall scene v] and wait
say [The end!] for (2) seconds
when I receive [go lake v]
switch backdrop to [Underwater 1 v]
broadcast [lake scene v] and wait
say [Gobo plays with the fish all day.] for (2.5) seconds
say [The end!] for (2) seconds
把所有按钮都藏起来
读故事的人一选好,两个按钮都要消失。不只是被点的那一个。
when I receive [go woods v]
hide
when I receive [go lake v]
hide
怎么用: 点绿旗。两个按钮出现后,点 The Woods 或 The Lake。
如果有个按钮忘了藏起来,会怎样?试一试就知道:
怎么用: 点绿旗。按钮出现后,先点 The Woods,然后马上点 The Lake。
基础任务:做出岔路口 24 分钟
第 1 步:新的地点
打开你上节课的故事。添加 Woods 和 Underwater 1 背景。添加 Fish 角色。
第 2 步:Wizard 提问
改一改 Wizard 的森林场景。让它用这个问题结束:
when I receive [forest scene v]
say [This is Gobo. Gobo lives in the forest.] for (2.5) seconds
say [Which way should Gobo go? You choose!] for (2.5) seconds
第 3 步:讲故事的人在岔路口停下
把 Wizard 的绿旗脚本改成“学一学”里那个短的。
第 4 步:两个按钮
做出 Woods button 和 Lake button。把 Woods button 拖到大约 (−110, −150),把 Lake button 拖到大约 (110, −150)。
第 5 步:按钮的脚本
每个按钮有五组积木。Woods button:
when flag clicked
hide
when I receive [fork v]
show
when this sprite clicked
broadcast [go woods v]
when I receive [go woods v]
hide
when I receive [go lake v]
hide
第 6 步:两条路
把“学一学”里的 go woods 和 go lake 两组积木加到 Wizard 身上。
第 7 步:Gobo 和 Fish
when I receive [woods scene v]
say [It is so quiet in the woods.] for (2) seconds
say [Look! I can see the castle!] for (2) seconds
when I receive [lake scene v]
say [Splash! I can swim!] for (2) seconds
say [Hello, fish!] for (2) seconds
when backdrop switches to [Woods v]
go to x: (0) y: (-110)
when backdrop switches to [Underwater 1 v]
go to x: (-40) y: (-20)
when backdrop switches to [Forest v]
hide
when backdrop switches to [Underwater 1 v]
show
第 8 步:试一试两条路,再想办法弄坏它
玩两次:一次去城堡,一次去湖。然后在岔路口用最快的速度乱点。永远只能有一条路在演。
怎么用: 点绿旗。按钮出现后,点 The Woods 或 The Lake。再玩一次,选另一个。
岔路口还没到,按钮就出现了。
有一个按钮少了 when flag clicked + hide 这组积木。两个都检查一下。
点按钮没有反应。
Wizard 在等 go woods,但按钮发的是另一条消息。打开两个下拉菜单,一个字母一个字母地对一对。
有一个按钮一直留在屏幕上。
那个按钮只在收到自己的消息时藏起来,收到另一条消息时不藏。每个按钮都需要两组藏起来的积木。
Wizard 还在说话,岔路口就出现了。
绿旗脚本用的是普通的 broadcast [forest scene v]。它需要 and wait 那块积木。这样岔路口就会在问题之后出现。
第三条路
- 在另外两个按钮中间加一个 Go Home 按钮。
- 它把 Gobo 带到 Bedroom 1 背景,他在那里说两句话。
- 点三个按钮里的任何一个,三个都会藏起来。
怎么用: 点绿旗。三个按钮出现后,点 Go Home、The Woods 或 The Lake。
Teacher reveal
A third message, go home, and a third path stack on the Wizard. The part most pupils miss: every button now needs three hide stacks — one for each path. Two buttons that do not know about go home stay on screen in the bedroom.
第二个岔路口
- 树林场景之后,故事又停下来。
- 两个按钮:The Castle 和 The Lake。
- The Castle 去大厅。The Lake 接上你已经做好的湖那条路。
怎么用: 点绿旗。在第一个岔路口点 The Woods,然后在第二个岔路口点 The Castle 或 The Lake。
Teacher reveal
when I receive [go woods v]
switch backdrop to [Woods v]
broadcast [woods scene v] and wait
broadcast [fork 2 v]
The Wizard’s woods path now ends at a second fork. The Lake button gets one more stack, when I receive [fork 2 v] + show, and a new Castle button sends go castle. The point to draw out: a message is not used up. go lake can be sent from two places.
回去的路
- 湖不再是结局了。
- 湖边场景之后,会出现一个 Go Back 按钮。
- 它把 Gobo 带回森林,岔路口又出现了。
怎么用: 点绿旗。点 The Lake,Go Back 出现后点它,然后点 The Woods。
Teacher reveal
when I receive [go lake v]
switch backdrop to [Underwater 1 v]
broadcast [lake scene v] and wait
broadcast [lake done v]
when I receive [go back v]
switch backdrop to [Forest v]
broadcast [fork v]
On the Wizard. The Go Back button shows on lake done, sends go back and hides on it. The fork buttons need no change at all: sending fork again shows them again. This is the first story with a loop in its map.
用键盘来选择
- 在岔路口,按 1 选树林,按 2 选湖。
- 用鼠标点还是可以的。
- 在其他时候按 1 或 2,什么都不会发生。
怎么用: 点绿旗,再点一下舞台。在岔路口,按 1 选树林,按 2 选湖。
总结 3 分钟
- 先画故事地图。每个方框都会变成一条消息。
- 按钮就是一个画着字的角色。
when this sprite clicked加上一个 broadcast,就是一个选择。- 讲故事的人在岔路口停下。读故事的人一点,下一部分就开始了。
- 每个按钮收到每条路的消息都会藏起来。这样就只有一条路能演。
- 岔路口(fork)
- 故事分开的地方。
- 路(path)
- 走完故事的一种方法。
- 分支(branch)
- 程序因为一个选择,走这条路或那条路。
- 故事地图
- 画出每个场景和每个岔路口的图。动手做之前先画好。
交作业
保存你的故事,发给老师。下一课,故事会记住读故事的人捡到了什么。