在地下的pygame blit中导致地下被锁定的错误 [英] In pygame blit of subsurface cause error that the subsurface is locked
本文介绍了在地下的pygame blit中导致地下被锁定的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是重现该内容的最小脚本
Here is a minimal script to reproduce that
#!/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 没有错误.
As you can see tuples with locks for screen and screen_half are empty. There is no error if I use screen instead of screen_half.
推荐答案
我遇到了类似的问题,pmoreli 是对的.我只是复制了次表面创建新表面,然后将其显示为 blit:
I had similar problem and pmoreli is right. I just copied subsurface creating new surface and than blit it on display:
screen_half = screen_half.copy()
screen_half.blit(screen_half, (0, 0))
这篇关于在地下的pygame blit中导致地下被锁定的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文