无法使用 pygame 创建游戏
我用 python 2.5 和 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上启动) 怎么了 。 抱歉我是初学者。
编辑 我可以找到 Python2.5\Lib\site-packages\pygame\freesansbold.ttf
但发生了同样的错误。 我可以在哪里复制 freesansbold.ttf
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'
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.
EDIT
I can find Python2.5\Lib\site-packages\pygame\freesansbold.ttf
but same error occured..
Where may I copy freesansbold.ttf
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
一个简单的解决方案是直接加载字体而不是使用 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.
您的计算机上的可访问字体文件夹中似乎没有
freesansbold.ttf
文件。 此字体应该随 Pygame 一起提供在lib
目录中。检查 Pygame 副本的安装文件夹,如果存在,请修改 Python 安装的字体路径以包含该目录。 如果没有,您需要找到 Pygame 的副本或下载更新版本。
It looks like you don't have the
freesansbold.ttf
file on your computer in an accessible fonts folder. This font should have come with Pygame in thelib
directory.Check the installation folder for your copy of Pygame, and if it's there, modify your Python installation's font path to include that directory. If not, you'll need to find a copy or download a newer version of Pygame.
您可能找到了解决方案,但我想为其他人提供一个解决方案。
使用 pygame 创建游戏。 然后,解压缩库文件。
去
回您解压缩的库文件并转到
将 freesansbold.ttf 放入并压缩库。
现在,工作了! :)
You probably found a solution but i want to give one for other.
Create you game with pygame. Then, unzip the librairy file.
Go to
Back to your library file that you unzipped and go to
Put freesansbold.ttf in and zip library.
Now, it's work ! :)