I want to get the color value of a pixel. I have read something about a function called "pygame.Surface.get_at()". But when I use this function i get this error:
Traceback (most recent call last):
pygame.Surface.get_at(300, 200)
TypeError: descriptor 'get_at' requires a 'pygame.Surface' object but received a 'int'
You have two problems here:
get_at
requires a tuple (x, y)
so you should invoke it with:
.get_at((300, 200))
You should provide the surface for which you want to get the pixel color. Something like this:
screen = pygame.display.set_mode((150, 50)) ... screen.get_at((300, 200))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.