0

使用以下代码:

import pygame
n = pygame.Surface((80,80))
m = pygame.surfarray.pixels3d(n)

m[1][1][1] = 255
del m

screen = pygame.display.set_mode((80,80))
screen.blit(n, (0,0))

给我错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
pygame.error: Surfaces must not be locked during blit

我不是刚刚删除了引用吗?

4

1 回答 1

0

好吧,这是 pygame 文档不清楚的情况。它说引用的表面将在数组的生命周期内被锁定,但删除数组实际上不会解锁它引用的表面。用于n.unlock()在 blitting 之前解锁表面。

于 2013-09-06T23:32:47.200 回答