2009-05-22 156 views
0

我使用python 2.5和pygame制作游戏。无法使用pygame创建游戏

但是,我无法完成制作。 ,因为这个错误发生。

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启动) 有什么问题。 抱歉,我是begginer。

编辑 我能找到的python2.5 \ LIB \站点包\ pygame的\ freesansbold.ttf

但同样的错误发生.. 我可以在哪里复制freesansbold.ttf

回答

1

它看起来就像您的计算机上的freesansbold.ttf文件没有可访问的字体文件夹一样。这个字体应该在lib目录中与Pygame一起提供。

检查Pygame副本的安装文件夹,如果存在,请修改Python安装的字体路径以包含该目录。如果没有,您需要找到一份副本或下载更新版本的Pygame。

+0

不错!我来试试 – freddiefujiwara 2009-05-22 01:55:28

2

一个简单的解决方案是直接加载字体而不是使用sysfont。只需使用pygame.font.Font类并直接加载一个ttf文件即可。这也将使它更容易使用py2exe,并且你可以选择你想要的字体。

0

你可能找到了一个解决方案,但我想给其他人一个。 用pygame创建你的游戏。然后,解压缩文件。 转到

PythonX.X \ LIB \站点包\ pygame的和复制freesansbold.ttf

返回到您的库文件,您解压缩和去

库\ pygame

把freesansbold.ttf放入zip库中。

现在,它的工作! :)