[Python] How to render transparent objects with transparency in Pygame

Discussão em 'Python' iniciado por Stack, Julho 2, 2025.

  1. Stack

    Stack Membro Participativo

    I have a .png file with a transparent cutout. I need to blit it to the screen with the transparency, but also with the entire image 50% transparency.

    self.costume = pygame.image.load("costumes/light2.png").convert_alpha()
    self.costume.set_alpha(128)
    self.screen.blit(self.costume, self.rect)


    If I understandPygame's transparency, this should blit "light2.png", 50% transparent, with the original transparency as well.

    But, this doesn't do that. All I get is a black screen. Is the self.costume.set_alpha(128) removing the original image's transparency? Is it possible to even do this?

    Continue reading...

Compartilhe esta Página