Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/354.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使pygame精灵的背景透明_Python_Pygame_Png - Fatal编程技术网

Python 如何使pygame精灵的背景透明

Python 如何使pygame精灵的背景透明,python,pygame,png,Python,Pygame,Png,这应该只是加载一个精灵到屏幕上,但图像的背景是这个黑匣子,我不想看到它。如何使图像的背景透明 from Tkinter import * import pygame from livewires import games #Creating screen window games.init(screen_width = 700, screen_height = 650, fps = 50) #creating background image for the screen screen_ba

这应该只是加载一个精灵到屏幕上,但图像的背景是这个黑匣子,我不想看到它。如何使图像的背景透明

from Tkinter import *
import pygame
from livewires import games

#Creating screen window
games.init(screen_width = 700, screen_height = 650, fps = 50)

#creating background image for the screen
screen_background = games.load_image('resized_stars background.png', transparent = False)
games.screen.background = screen_background

#Creating a sprite
spaceship_image = games.load_image('pixel_spaceship.png')
spaceship = games.Sprite(image = spaceship_image, x=350, y=235)
games.screen.add(spaceship)

#main loop at the end of the program just as in tkinter
games.screen.mainloop()
你的形象需要是一个好的形象。例如,打开预览,并使用alpha工具删除背景,从而增加透明度

之前

之后


寻找使图片透明的工具。

谢谢您的帮助!对不起,如果这是个愚蠢的问题。但是我用AdobePhotoshop去除了背景,当我把图像加载到程序中时,它有一个奇怪的背景,黑色的,五颜六色的透明斑点。那么为什么Photoshop不能工作呢?