Pyglet:Sprite.draw()和Batch.draw()不起作用,但是Image.blit起作用 [英] Pyglet: Sprite.draw() and Batch.draw() don't work, but Image.blit does

查看:177
本文介绍了Pyglet:Sprite.draw()和Batch.draw()不起作用,但是Image.blit起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我正在学习的pyglet中,Image.blit()可以工作,但Sprite.draw()不能,或者Batch.draw()也不起作用,即使在以下简单代码中也是如此:

In pyglet, which I'm learning, Image.blit() works, but Sprite.draw() doesn't, nor Batch.draw(), even in this simple code:

import pyglet

win = pyglet.window.Window()

img = pyglet.resource.image('test.png')
spr = pyglet.sprite.Sprite(img)

@win.event
def on_draw():
    win.clear()
    spr.draw()


if __name__ == '__main__':
    pyglet.app.run()

窗口保持黑色。但是,例如,我可以绘制标签。
我发现的唯一解释是关于图形卡和其中的一些 v2i错误,但我害怕不真正知道自己在做什么就接触pyglet的代码。

The window remains black. However, I can draw labels, for example. THe only explaination I found was about graphic cards and "v2i" bugs with some of them, but I'm afraid to touch at pyglet's code without really knowing what I'm doing.

推荐答案

这的第三个答案线程为我工作,即使我使用的是Ubuntu,而不是Windows。这实际上是硬件问题。我在/usr/lib/pymodules/python2.7/pyglet/sprite.py找到的文件中的 v2i中的第368和372行处,用 f替换了 i。然后我保存并运行了代码,一切正常。

The third answer of this thread worked for me, even though I'm using Ubuntu and not Windows. It's actually a hardware problem. I replaced the "i" with the "f" at lines 368 and 372 in "v2i" in a file I found at /usr/lib/pymodules/python2.7/pyglet/sprite.py. Then I saved, ran my code, and everything was working.

这篇关于Pyglet:Sprite.draw()和Batch.draw()不起作用,但是Image.blit起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆