0
我试图在pygame屏幕上创建一个透明表面,不幸的是没有工作。主表面显示正常,但我尝试生成的表面完全不显示。PyGame,表面没有显示
import pygame as pg
from pygame.locals import *
pg.display.init()
h = 640
w = 480
_display = pg.display.set_mode((h,w))
_display.fill(pg.Color(0,0,0))
_active_surface = pg.Surface((h,w))
#_active_surface.set_colorkey((255,0,255))
_active_surface.fill(pg.Color(255,0,255))
_display.blit(_active_surface, (h,w))
while True:
for i in pg.event.get():
if i.type == QUIT:
pg.quit()
pg.display.flip()
如果它是透明的......你真的能看到它吗? – Chachmu
@Roboinventor行_active_surface.set_colorkey((255,0,255))使其透明,并禁用它。 – dantebarba
你应该改变你的h和w变量为w和h。 –