0

I am attempting to use a batch in pyglet to draw labels. Currently this batch is used for drawing every entity that I create, and everything draws just fine. I can add hundreds of Sprites to it and they will all be drawn, but not any labels that I create and add. I am using the latest version of pyglet from the source repository, and here is the code that I am using:

def _text(self, command):
    uid, x, y, chars, font, size, level = command[1:]
    print 'Text - uid=%s, x=%s, y=%s chars=%s, font=%s, size=%s, level=%s' % (uid, x, y, chars, font, size, level)
    self._ents[uid] = (pyglet.text.Label(chars,
        color=(0, 0, 0, 0),
        font_name=font,
        font_size=size,
        batch=self._batch,
        group=self._get_level_group(level)), level)
    print self._ents[uid][0].batch

The printed batch has the same memory address for every Label I create, and the same as what is given to any Sprites I create. I attempted to dig into the source code a bit and try to find out what was going wrong, but at every point that I printed out the batch the memory address is the same. The odd part is that when I put a print statement in a location where the Label will draw itself one way if it owns its own batch, or if it was given a batch, it will only print stuff out under the branch where it owns its own batch. If I print out the memory address of the batch at that point, it is different from every other time. Somehow it seems like it is seeing that it should own its own batch, and is creating a new one instead of the one that I provide.

EDIT: I feel dumb. It works fine with this code... once I add x=x, y=y in the Label creation code. It was defaulting to the bottom-left of the screen, and the characters I was trying to draw were underscores, so I couldn't see them. I'll either add an answer to this question once SO lets me, or someone else can put in an answer for the x/y thing and I'll accept it.

Freezerburn
  • 1,013
  • 3
  • 11
  • 29
  • Hi. If you've solved the problem you should answer your own question and mark as accepted instead of editing the question. – darkfeline Sep 03 '12 at 19:15
  • Oh right. I was planning on answering it, but it hadn't been enough time for me to do that yet. Then I forgot. I'll get right on putting that answer up. Thanks for the reminder :) – Freezerburn Sep 05 '12 at 00:35

1 Answers1

0

I feel dumb. It works fine with this code... once I add x=x, y=y in the Label creation code. It was defaulting to the bottom-left of the screen, and the characters I was trying to draw were underscores, so I couldn't see them. I fixed this and now everything is fine.

Freezerburn
  • 1,013
  • 3
  • 11
  • 29