python - 在地下的pygame blit中导致地下被锁定的错误

标签 python pygame

这是一个最小的脚本来重现它

#!/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

如您所见,带有 screenscreen_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/

相关文章:

python - 非线性回归中的标准误差

python - 如何让 python 窗口以 "Always On Top"运行?

python - 如何使用特定的解释器运行 python 脚本?

python - 如何在pygame中添加残像?

python - 如何使用 pygame 将整个像素数组放在屏幕上?

python - 每十年检索一次

python - 将许多 python pandas 数据框放到一个 excel 工作表中

python - 在内存缓存或数据存储中存储数据存储游标的位置?

python - Pandas :多列合并为一列

python pygame - 以set_timer事件为中心的相机