For some reason, I can't get pyglet to draw sprites. Here is my code:
import pyglet game = pyglet.window.Window(640, 480, "I'm a window") batch = pyglet.graphics.Batch() pyglet.resource.path = ["."] pyglet.resource.reindex() image = pyglet.resource.image("hextile.png") pyglet.sprite.Sprite(image, x=200, y=300, batch=batch) pyglet.text.Label('DING', font_name='Arial', font_size=24, x=100, y=100, batch=batch) @game.event def on_draw(): game.clear() batch.draw()
Now, when I draw the package, the text label is displayed correctly. I see "DING" on the window. However, the image "hextile.png" is not displayed. I tried to draw the sprite myself, but that didn't work either. However, the sparkle of the image (as shown in the commented line) seems to work very well, but itβs obvious that the functionality that I am here is not quite. I can not understand this. What am I missing?
source share