gpt4 book ai didi

pyglet - pyglet中找不到资源异常

转载 作者:行者123 更新时间:2023-12-04 07:58:28 43 4
gpt4 key购买 nike

我正在使用Python 2.6.6和pyglet 1.1.4。在我的“Erosion”文件夹中,有“Erosion.py”和一个名为“Images”的文件夹。在图像内部,有.png图像。一幅图像被命名为“Guard.png”。

在“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放在同一文件夹中。

最佳答案

这是我能够加载资源的方法:

pyglet.resource.path = ['C:\\Users\\myname\\Downloads\\temp']
pyglet.resource.reindex()

pic = pyglet.resource.image('1.jpg')

texture = pic.get_texture()
gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST)

texture.width = 960
texture.height = 720

texture.blit(0, 0, 0)

关于pyglet - pyglet中找不到资源异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6541494/

43 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com