无法使用pygame创建游戏 [英] Can't create games with pygame
问题描述
我用python 2.5和pygame制作游戏.
I make a game with python 2.5 and pygame.
但是,我不能完成化妆. 因为发生了此错误.
but,I can't complete make. because this errors occured.
C:\Python26\TypeType\src\dist\Main.exe:8: RuntimeWarning: use font: MemoryLoadLibrary failed loading pygame\font.pyd
Traceback (most recent call last):
File "Main.py", line 8, in <module>
File "pygame\__init__.pyo", line 70, in __getattr__
NotImplementedError: font module not available
Traceback (most recent call last):
File "Main.py", line 8, in <module>
File "pygame\sysfont.pyo", line 253, in SysFont
RuntimeError: default font not found 'freesansbold.ttf'
也许我认为原因是因为它使用了一个名为sysfont的对象. (因为我的程序没有在执行文件上使用sysfont,并且能够从未安装Python的PC上启动) 怎么了 . 抱歉,我是乞gg.
Perhaps I think that the reason is because it used an object called sysfont. (Because I had the programs that did not use sysfont on an execute file and was able to start with the PC which was not installed Python in) What's wrong . sorry I'm begginer.
编辑 我可以找到Python2.5 \ Lib \ site-packages \ pygame \ freesansbold.ttf
EDIT I can find Python2.5\Lib\site-packages\pygame\freesansbold.ttf
,但发生相同的错误. 我可以在哪里复制freesansbold.ttf
but same error occured.. Where may I copy freesansbold.ttf
推荐答案
一个简单的解决方案是直接加载字体而不使用sysfont.只需使用pygame.font.Font类并直接加载ttf文件即可.这也将使使用py2exe更容易,并且您可以完全选择所需的字体.
A simple solution would be to simply load the font directly instead of using sysfont. Just use the pygame.font.Font class and directly load a ttf file. This will also make it easier to use py2exe, and you can choose exactly the font you want.
这篇关于无法使用pygame创建游戏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!