pyglet中找不到资源异常

Jac*_*ack 8 pyglet

我正在使用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'))
Run Code Online (Sandbox Code Playgroud)

当我跑这个,我得到了

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.
Run Code Online (Sandbox Code Playgroud)

我尝试将路径更改为['./''和['../Images'].我也尝试删除路径和reindex调用,并将Erosion.py和Guard.png放在同一个文件夹中.

Tor*_*xed 5

这是我为了能够加载资源而做的事情:

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)
Run Code Online (Sandbox Code Playgroud)


Jim*_*yap 2

尝试这个

pyglet.image.load('path/to/image.png')
Run Code Online (Sandbox Code Playgroud)