2009-05-22 91 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庫中。

現在,它的工作! :)