帧动画是一种图像切换做出的较为连贯的动画。在播放帧动画时,使用for语句显示出一系列图像。
[Python] 纯文本查看 复制代码 self.count = 0
# 绘制主角
def draw(self, screen, direction):
# 【你需要在这里编写 [主角方向选择与帧动画切换] 的代码】
self.count += 1
if direction == 'left':
self.image = self.left_list[self.count % 8]
elif direction == 'right':
self.image = self.right_list[self.count % 8]
elif direction == 'up':
self.image = self.up_list[self.count % 8]
elif direction == 'down':
self.image = self.down_list[self.count % 8]
|