乒乓球小游戏规则
1、乒乓球在屏幕上自由弹跳;
2、当乒乓球碰到屏幕下方的红线时游戏结束;
3、可以用鼠标控制反弹板把下落的乒乓球弹回;
4、反弹板每成功弹回一次得1分;
5、得到5分即为胜利。功能
功能
分解
1.小球四处反弹
2.移动反弹板
3.小球碰到反弹板弹起
4.小球碰红线游戏结束
5.设置比分
6.游戏胜利提示
接下来,跟我一步一步实现吧!
小球四处反弹
01
实现功能:让小球在舞台上反弹移动
-
在“舞台”中“选择一个背景图”


-
在右下角的角色区“选择一个角色”

-
增加角色--小球(ball)

-
给小球添加下面的积木代码

移动反弹板
02
实现功能:用鼠标控制反弹板的移动
-
先在角色里面绘制一个反弹板

-
把绘制好的反弹板拖曳到舞台的底部

-
给“反弹板”添加一段代码

小球碰到反弹板弹起
03
实现功能:让小球从反弹板上弹起
-
点击并选择Ball(小球)角色

-
给小球增加下面的代码。

小球碰到红线游戏结束
04
实现功能:当小球碰到红线时停止游戏
-
选择舞台,进入“背景”页签,选择“矩形框”在背景底部画出一条红线。

-
给小球角色增加下面代码

设置比分
05
实现功能:每当小球碰到反弹板后“得分”增加1
-
新建一个变量,用来记录得分情况

-
在小球的代码上增加积分累计

游戏胜利提示
06
实现功能:当得分达到5分时显示胜利的提示!
-
点击笔刷绘制一个新角色,使用文本工具输入一条消息,比如:“You won!”
-
可以选择自己喜欢的文字的颜色、字体和大小。

-
给“获胜提示语”增加代码
-
这里我们设置“5分”为胜利,你也可以设置自己的获胜规则。

现在点击“绿旗”来运行你的小游戏吧!
在这个基础上你还可以自由发挥哟,试试换成你喜欢的背景、加上各种音效、交互特效,期待看到你不一样的作品……
--end--
声明:转载此文是出于传递更多信息之目的。若有来源标注错误或侵犯了您的合法权益,请作者持权属证明与本网联系,我们将及时更正、删除,谢谢。