正如标题中所说,我无法在我拥有的精灵上使一种颜色透明。我将颜色键设置为白色,但精灵上的空白区域不会变得透明。
这是我所拥有的:
player_image = pygame.image.load("blanksprite.png").convert()
player_image.set_colorkey(white)
screen.blit(player_image, [x,y])
我对 Pygame 还很陌生,但是如果你使用Surface.convert_alpha
而不是 ,它会起作用Surface.convert
吗?
player_image = pygame.image.load("blanksprite.png").convert_alpha()
I placed 'player_image.set_colorkey(white)' in the wrong place, after the image was blitted at first, and before the main program. I moved it to right before the image was to be blitted and it became transparent.