键盘事件添加列表

This commit is contained in:
206530332 2021-06-15 14:35:19 +08:00
parent 1106f939c0
commit bbd5aeaced
1 changed files with 11 additions and 0 deletions

View File

@ -112,4 +112,15 @@ class HeroPlane(object):
elif self.key_down_list[0] == pygame.K_s:
self.move("DOWN")
# 键盘按下向列表添加space
def space_key_down(self, key):
self.space_key_list.append(key)
# 键盘松开向列表删除space
def space_key_up(self, key):
if len(self.space_key_list) != 0: # 判断是否为空
try:
self.space_key_list.remove(key)
except Exception:
raise