我正在创建一个程序,并且如果光标位置处的像素还不是黑色,则尝试在光标位置绘制一个矩形。
if pygame.Surface.get_at(pygame.mouse.get_pos()) != (0,0,0,255):
pygame.draw.rect(win, (0,0,0), (x, y, 3, 3))
当我尝试实现 pygame.Surface.get_at() 时发生错误,提示...
TypeError: descriptor 'get_at' for 'pygame.Surface' objects doesn't apply to a 'tuple' object
..即使 pygame.Surface.get_at() 的文档https://pygame.org表明该方法的输入应该是一个元组。
get_at()
get the color value at a single pixel
get_at((x, y)) -> Color
Return a copy of the RGBA Color value at the given pixel. If the Surface has no per pixel alpha, then
the alpha value will always be 255 (opaque). If the pixel position is outside the area of the Surface
an IndexError exception will be raised.
我怎样才能解决这个问题?