Pygame error: display surface quit: Why?

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

Can anyone tell me why my app quits with:

pygame error: display Surface quit.

8条回答
  •  萌比男神i
    2020-12-04 02:28

    I too had this problem, and similar to Maciej Miąsik's answer mine had to do with copy.deepcopy()-ing an image.

    I had:

    import copy,pygame,sys
    from pygame.locals import *
    
    EMPTY_IMG= pygame.image.load('C:super/fancy/file/path/transparent.png')
    held_image=copy.deepcopy(EMPTY_IMG)
    my_rect=held_image.get_rect()
    my_rect.center = (50,50)
    screen.blit(held_image,my_rect)
    

    And I got the same error.

    I simply changed the copy.deepcopy(EMPTY_IMG) to just EMPTY_IMG.

    import copy,pygame,sys
    from pygame.locals import *
    
    EMPTY_IMG= pygame.image.load('C:super/fancy/file/path/transparent.png')
    held_image=EMPTY_IMG
    my_rect=held_image.get_rect()
    my_rect.center = (50,50)
    screen.blit(held_image,my_rect)
    

    Then it all worked fine.

提交回复
热议问题