Если вы хотите смешать разные слои, вам нужно создать разные pygame.Surface
с или изображения. Примечание pygame.image
создание поверхностей.
Создайте прозрачную поверхность и сделайте ее полностью прозрачной. Это мера заполнить его pygame.Color(0, 0, 0, 0)
:
alpha_surface1 = pygame.Surface( (screen.get_rect().width, screen.get_rect().height) )
alpha_surface1 = alpha_surface1.convert_alpha()
alpha_surface1.fill( pygame.Color(0, 0, 0, 0) )
Нарисуйте на поверхности что угодно, например, прямоугольник
pygame.draw.rect(alpha_surface1, (247, 137, 0, 255), (120, 120, 480, 480))
blit()
поверхность на экране:
screen.blit(alpha_surface1, (0,0))
Повторите это с несколькими поверхностями:
* * Например, тысяча двадцать-три
#fill screen with red
screen.fill(pygame.Color(247, 25, 0,255))
#fill surface with orange
alpha_surface1 = pygame.Surface( (screen.get_rect().width, screen.get_rect().height) )
alpha_surface1 = alpha_surface1.convert_alpha()
alpha_surface1.fill( pygame.Color(0, 0, 0, 0) )
pygame.draw.rect(alpha_surface1, (247, 137, 0, 255), (120, 120, 480, 480))
#fill surface 2 with translucent yellow
alpha_surface2 = pygame.Surface( (screen.get_rect().width, screen.get_rect().height) )
alpha_surface2 = alpha_surface2.convert_alpha()
alpha_surface2.fill( pygame.Color(0, 0, 0, 0) )
pygame.draw.rect(alpha_surface2, (220, 247, 0, alpha), (240, 240, 360, 360))
#fill surface 3 with green
alpha_surface3 = pygame.Surface( (screen.get_rect().width, screen.get_rect().height) )
alpha_surface3 = alpha_surface3.convert_alpha()
alpha_surface3.fill( pygame.Color(0, 0, 0, 0) )
pygame.draw.rect(alpha_surface3, (0, 247, 4), (360, 360, 240, 240) )
#fill surface 4 with translucent blue
alpha_surface4 = pygame.Surface( (screen.get_rect().width, screen.get_rect().height) )
alpha_surface4 = alpha_surface4.convert_alpha()
alpha_surface4.fill( pygame.Color(0, 0, 0, 0) )
pygame.draw.rect(alpha_surface4, (0, 78, 247, alpha), (480, 480, 120, 120) )
# blend surface1 on screen
screen.blit(alpha_surface1, (0,0))
# blend surface2 on screen
screen.blit(alpha_surface2, (0,0))
# blend surface3 on screen
screen.blit(alpha_surface3, (0,0))
# blend surface4 on screen
screen.blit(alpha_surface4, (0,0))
![](https://i.stack.imgur.com/OiIzC.gif)