您的位置首页百科知识

Kittenblock实例,移动效果,碰触边缘反弹

Kittenblock实例,移动效果,碰触边缘反弹

的有关信息介绍如下:

Kittenblock实例,移动效果,碰触边缘反弹

程序解读:小猫移动效果,碰触边缘反弹,左右翻转

知识点:角色移动,程序循环,碰触边缘反弹,左右翻转

涉及的软件:scratch3.0 (.sb3)、Python、Kittenblock。

1定义角色和背景,Cat = Sprite("Cat")

2设置触发条件,小旗子被点击

3调用控制模块,循环效果,while True:

4调用运动模块,设置小猫移动速度为1,Cat.motion_movesteps(1)

5调用外观模块,选择下一个造型,Cat.looks_nextcostume()

6调用控制模块,设置造型改变的间隔时间,time.sleep(0.2)

7碰到边缘反弹,旋转方式为左右翻转,

Cat.motion_ifonedgebounce()

Cat.motion_setrotationstyle("left-right")