最初,我在这里进行了搜索之后,发现了一个与我完全相同的问题: Pygame window not responding after a few seconds。我查看了所有答案并进行了尝试,但没有一个起作用。我尝试使用for循环遍历每个事件;
run = True
while run:
for event in pygame.event.get():
if event == pygame.QUIT()
run = False
但是窗口仍然关闭。我也尝试过:
run = True
while run:
event = pygame.event.get()
if event == pygame.QUIT():
run = False
与上述结果相同。 有人可以帮忙吗? 编辑:我使用PyCharm和MacOS Catalina。
答案 0 :(得分:3)
expo build:ios -t simulator
是一个常量,而build:ios
是一个调用语句。拆下支架。无论如何,该条件将不起作用,因为您必须将事件的pygame.QUIT
属性与事件类型常量进行比较(请参见pygame.event
)。此外,pygame.QUIT()
语句的末尾缺少type
。
:
if
此外,Indentation不正确:
if event == pygame.QUIT()