【发布时间】:2020-05-13 09:29:32
【问题描述】:
我是 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
【问题讨论】:
-
当我在 Linux Mint(使用 PyGame 1.9.6)上运行时,它会一直打印 - 所以它可能取决于您使用的系统。当您移动窗口时,可能某些系统会停止运行代码 - 这可能是您系统中的正常现象。
-
虽然也没有明确的答案,但这是同一个问题:stackoverflow.com/questions/10122289/…
标签: python pygame drag-and-drop window code-freeze