Traceback (most recent call last):
File "D:/game/main.py", line 28, in <module>
launch.load_key()
File "D:\game\Class_and_funtion_keeper\keys.py", line 57, in load_key
self._look = pygame.image.load("outside_information\person_information\Person.bmp",).convert_alpha()
pygame.error: No video mode has been set
libpng warning: iCCP: known incorrect sRGB profile
Process finished with exit code 1
这个是代码,self.work 为True
def load_key(self):
if self.work:
self._look = pygame.image.load("outside_information\person_information\Person.bmp",).convert_alpha()
但是,在另一个类中的函数却没问题
def __init__(self, background_picture, mince_picture, screen_width, screen_height, name, kind=0, icon_name=None, ):
self.background_picture = background_picture
self.mince_picture = mince_picture
self._screen_name = name
def load_background_and_mice(self, ):
"""load picture"""
self._background = pg.image.load(self.background_picture).convert()
self._mice = pg.image.load(self.mince_picture).convert_alpha()
2 个解决方案
#1
好的,知道了,要在屏幕创建后
#2
#1
好的,知道了,要在屏幕创建后