Currently, I'm trying to paste a picture to my pygame game and this picture have a alpha channel (as you can see bellow this sentence).
But, for some reason, when I use convert()
or convert_alpha()
, it's not putting correctly the picture with the alpha channel on the game... Even when I tried to do some mainpulations of the picture, nothing.
What happened (with the manipulations)
Here is the code I tried to write (with the manipulations for alpha channel that it didn't worked) :
class Spritesheet:
# utility class for loading and parsing spritesheets
def __init__(self, filename):
self.spritesheet = pygame.image.load(filename).convert()
def get_image(self, x, y, width, height):
# grab an image out of a larger spritesheet
image = pygame.Surface((width, height))
image.fill(pygame.color.Color("black"))
image.blit(self.spritesheet, (0, 0), (x, y, width, height))
image.set_colorkey(pygame.color.Color("black"))
return image
How can I put a picture who have originally the alpha channel on it?