Pygame error: display surface quit: Why?

前端 未结 8 1482
孤独总比滥情好
孤独总比滥情好 2020-12-04 01:54

Can anyone tell me why my app quits with:

pygame error: display Surface quit.

8条回答
  •  自闭症患者
    2020-12-04 02:36

    import pygame, sys
    
    running = True
    while running:
        for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit() # quit the screen
            running = False
            sys.exit()
    

    call sys.exit() after pygame.quit() to stop the program so you can not change the surface after you have quit pygame and not get the error

提交回复
热议问题