现在,我有这个:
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True
keys = pygame.key.get_pressed()
# moves hero with key presses
if keys[pygame.K_LEFT] == 1:
hero.goLeft()
if keys[pygame.K_RIGHT] == 1:
hero.goRight()
elif keys[pygame.K_UP] == 1:
hero.goUp()
elif keys[pygame.K_DOWN] == 1:
hero.goDown()
但是,我仍然需要多次按键才能移动角色。有谁知道为什么或有不同的解决方案?
谢谢!