python - 添加空闲播放位置。游戏
问题描述
所以我正在关注一个 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
解决方案
推荐阅读
- mongodb - Mongodb cursor.toArray() 太慢了
- javascript - 随机比较数组中的每个元素
- ios - 从 AppDelegate 中访问 NavigationController 指向的初始视图
- php - 获取 Laravel 数据库连接以处理单个 PHP 脚本
- java - 具有 Recyclerview onclicks 的多项活动
- csv - 在“csv”中找不到“ReaderBuilder”
- ios - 使用 Firebase 匿名登录会影响 Facebook 登录
- django - `ModelForm`中的标签是什么
- drupal - 来自 PHP 文件的 Drupal 8 服务调用
- python - Pip 全局安装不起作用