这是一个最小的脚本来重现它
#!/usr/bin/env python
import pygame
screen = pygame.display.set_mode((640, 480))
screen.fill((255, 255, 255))
screen_half = screen.subsurface((0,0, 640/2.0, 480))
print screen.get_locks()
print screen_half.get_locks()
screen_half.blit(screen_half, (0, 0))
输出是
()
()
Traceback (most recent call last):
File "./blit_test.py", line 10, in <module>
screen_half.blit(screen_half, (0, 0))
pygame.error: Surfaces must not be locked during blit
如您所见,带有 screen 和 screen_half 锁的元组是空的。如果我使用 screen 而不是 screen_half 则没有错误。
最佳答案
我有类似的问题,pmoreli 是对的。我只是复制了 subsurface 创建新的表面,然后将其 blit 显示出来:
screen_half = screen_half.copy()
screen_half.blit(screen_half, (0, 0))
关于python - 在地下的pygame blit中导致地下被锁定的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4117407/