您可能遇到的另一个问题(除了猴子所说的)是您可能需要使用surface.convert()将图像转换为可以更改alpha的形式.您可以执行以下任一操作.
image = pygame.image.load("logo.png")
image = image.convert()
要么
image = pygame.image.load("logo.png").convert()
我发现,虽然surface.convert_alpha()应该做同样的事情,但它通常不起作用.试试这个测试代码来检查.
import pygame, sys
pygame.init()
window=pygame.display.set_mode((1500, 800))
background=pygame.Surface((window.get_rect().width, window.get_rect().height))
background.fill((0, 0, 0))
image=pygame.image.load('InsertImageHere.png')
image=image.convert()
image2=pygame.image.load('InsertImage2Here.png')
image2=image2.convert_alpha()
rect=image.get_rect()
rect2=image2.get_rect()
rect2.left=rect.width+1
i=1
while True:
for event in pygame.event.get(