Hi there! We use translucent surfaces in order to apply a tint to images and do things like fade in and out. It looks like Pygame_SDL2's set_alpha() function on surfaces isn't working.
The following code draws a semi-transparent red box over a white box in Pygame:
But it draws a solid red box in Pygame_SDL2:
Code to reproduce it is below:
# Comment out these two lines to go back to old Pygame version
import pygame_sdl2
pygame_sdl2.import_as_pygame()
import pygame
from pygame import KEYDOWN, QUIT
import sys
def main():
pygame.init()
tilesize = 35
size_x = 24
size_y = 18
screen_size = (tilesize * size_x, tilesize * size_y)
screen = pygame.display.set_mode(screen_size, 0, 32)
clock = pygame.time.Clock()
stop_flag = False
block = pygame.Surface((300,300))
block.fill((255,255,255))
overlay_block = pygame.Surface((300,300))
overlay_block.fill((255,0,0))
overlay_block.set_alpha(140)
while not stop_flag:
for event in pygame.event.get():
if event.type == QUIT:
sys.exit()
screen.fill((200,200,200))
screen.blit(block, (50,50))
screen.blit(overlay_block, (100,100))
pygame.display.flip()
clock.tick(60)
if __name__ == '__main__':
main()
Hi there! We use translucent surfaces in order to apply a tint to images and do things like fade in and out. It looks like Pygame_SDL2's set_alpha() function on surfaces isn't working.
The following code draws a semi-transparent red box over a white box in Pygame:
But it draws a solid red box in Pygame_SDL2:
Code to reproduce it is below: