Pygame screen freezes when I close it

前端 未结 4 1638
Happy的楠姐
Happy的楠姐 2021-01-21 01:19

The code loads up a pygame screen window, but when I click the X to close it, it becomes unresponsive. I\'m running on a 64-bit system, using a 32-bit python and 32-bit pygame.<

4条回答
  •  暖寄归人
    2021-01-21 01:32

    Mach1723's answer is correct, but I would like to suggest another variant of a main loop:

    while 1:
        for event in pygame.event.get():
            if event.type == QUIT: ## defined in pygame.locals
                pygame.quit()
                sys.exit()
    
            if event.type == ## Handle other event types here...
    
        ## Do other important game loop stuff here.
    

提交回复
热议问题