I have this function for a game, message_box, which shows a nice background(a Sprite) and in the top of it, a label(it's text is the string
parameter received).
When I call the method draw() of it, it works, and the sprite is shown in the screen. But I need to use it in a batch, so it can be rendered with other elements(a Label in this case). Sadly, only the label get rendered. I've tried using the batch with only the Sprite but again, no luck.
Here is the code:
def message_box(self, string):
batch = pyglet.graphics.Batch()
dialog = pyglet.text.Label(string + " (Press ESC)",
font_name="Arial",
font_size=12,
x=cfg.resolution[0] / 3 + 26,
y=400,
anchor_x="center", anchor_y="center", batch=batch)
img = pyglet.resource.image('gui/dialog_full.png')
dia = pyglet.sprite.Sprite(img, batch=batch)
dia.x = 26
dia.y = 196
batch.draw()
I'm a beginner in python and pyglet, so I really have no clue what's happening here.