我使用Python 2.6.6和pyglet 1.1.4。在我的“Erosion”文件夹中,我有“Erosion.py”和一个名为“Images”的文件夹。里面的图像,有.png图像。一个图像被命名为“Guard.png”。资源未找到pyglet异常
在 “Erosion.py” 有是去像这样的一段:我试图改变
pyglet.resource.path = ['Images']
pyglet.resource.reindex()
self.image = pyglet.resource.image('%s%s' % (character, '.png'))
当我运行此,我给
File "C:\Python26\lib\site-packages\pyglet\resource.py", line 394, in file raise ResourceNotFoundException(name)
ResourceNotFoundException: Resource "Guard.png" was not found on the path. Ensure that the filename has the correct captialisation.
指向['./Images']和['../Images']的路径。我也尝试删除路径和reindex调用,并将Erosion.py和Guard.png放在同一个文件夹中。
http://www.pyglet.org/doc/programming_guide/playing_sounds_and_music.html 更多关于加载资源 –