Pygame:当我移动窗口时,游戏暂时停止

时间:2020-05-13 09:29:32

标签: python pygame drag-and-drop window code-freeze

我是PyGame的新手,我在做游戏。直到我发现,例如,当您将窗口移动到桌面的另一个位置时,游戏才暂时停止。但是当我使用pygame.time.get_ticks()时,游戏的滴答声仍在运行。

因此,我只用了必要的代码制作了一个全新的程序,它执行相同的操作。

有人可以解释一下为什么这样做,如果我们可以解决这个问题?

import pygame

screen = pygame.display.set_mode((800,600))
pygame.display.set_caption('The Test Program')

running = True
update_counter = 1

while running:
  for event in pygame.event.get():
    if event.type == pygame.QUIT:
      running = False

  pygame.display.flip()
  print(str(update_counter) + " updates")
  update_counter += 1


pygame.quit()
quit()
# So try to move the window across your screen and you will see that, prints will stop and they will resume when you will release the click

1 个答案:

答案 0 :(得分:0)

所以有人告诉我这很正常,所以我认为它仅在Windows上没有解决方案。我放置了一个脚本,当光标离开窗口使其正常时,该脚本在屏幕上显示一个暂停符号。

相关问题