
上QQ阅读APP看书,第一时间看更新
5.2 Scratch猴子程序
Scratch程序
先把需要的素材放到舞台上。

声音(Chee Chee)背景(Jungle)

Scratch自带的(monkey)有三个造型

程序运行,小猴子问你叫什么名字,输入名字。
编写程序

程序的源代码
程序里会使用到以下模块。

孙悟空的72变。控制猴子变大,变小,变颜色,及左、右移动的程序。

通过不同的按键,来控制猴子的变化。

这几个模块的使用方法如下。

金箍棒

这是一个使用键盘按键使金箍棒变大、变小的程序。
上、下、左、右键控制金箍棒,空格键控制猴子。
按〈上〉键,金箍棒变大。按〈下〉键,金箍棒变小。〈左〉键左移,〈右〉键右移。
按住空格键,猴子左右移动,碰到边缘就反弹。
可以根据需要增加声音,以及其他更多的按键控制效果。
金箍棒程序

猴子的源程序


金箍棒源程序

筋斗云程序

这是猴子脚下有筋斗云的源程序,加入了控制筋斗云跟随猴子的按键。

筋斗云

金箍棒源程序


筋斗云源程序
