首页 > 解决方案 > 添加空闲播放位置。游戏

问题描述

所以我正在关注一个 pygame 平台游戏的教程。在本教程中,用户通过一扇门进入了每个关卡,我的游戏将以空间为主题,我尝试使用这个像素宇宙飞船,当我打开图像时,它显示的棋盘格指示背景是透明的,但是当我将图像加载到 pycharm 并将其绘制到具有白色背景的屏幕上。

怎么让背景透明

这是我使用的代码

class Exit(pygame.sprite.Sprite):
def __init__(self, x, y):
    pygame.sprite.Sprite.__init__(self)
    img = pygame.image.load('img/exit.png')
    self.image = pygame.transform.scale(img, (tile_size, int(tile_size * 1.5)))
    self.rect = self.image.get_rect()
    self.rect.x = x
    self.rect.y = y

标签: pythonpygame

解决方案


推荐阅读