【发布时间】:2020-02-29 21:33:34
【问题描述】:
我目前正在进行一个 pygame 项目,并希望显示一些文本。我以前在另一个程序中做过这个,它工作得很好,但是当我在这个项目中写完全相同的东西时,它给出了这个错误:
Traceback (most recent call last): File "C:\Users\Fazelifar\Desktop\Dot Game.py", line 197, in <module> myfont = pygame.font.SysFont(None, 15) File "C:\Users\Fazelifar\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pygame\sysfont.py", line 362, in SysFont return constructor(fontname, size, set_bold, set_italic) File "C:\Users\Fazelifar\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pygame\sysfont.py", line 285, in font_constructor font = pygame.font.Font(fontpath, size) pygame.error: font not initialized
这是我的代码:
myfont = pygame.font.SysFont(None, 15)
def txt_display (txt , color , x , y):
txt = lala.render(txt , True , black)
main.blit(txt , (x , y))
请帮助我卡住了
【问题讨论】: