On Mon, Apr 16, 2012 at 3:50 PM, Nitneroc <[email protected]> wrote:

> As I said in another thread, I'm a newbie, so I hope my question isn't
> totally stupid.
>
> I have Sprite objects, with a name displayed above them. This name is a
> cocos2d Label. For speed-ups, I wanted to put the Sprites in a batch, so I
> just tried to add them as children to the BatchNode. This raised an error
> because the Label isn't a BatchableNode. I knew things couldn't be that
> easy, but I tried to create my own Label class that inherited from
> BatchableNode, and the exception disappeared, but there is only one of my
> labels displayed, and I don't really understand how to make it work...
>
> In fact I don't know a thing about how batches manage to speed-up drawing
> operations, I guess it's by calling draw for objects with the same graphics.
>

No, batches speed-up comes from drawing as many vertexs in as few calls to
openGL as possible, and minimizing the number of openGL state changes.

For a 10000ft overview see
http://www.pyglet.org/doc/programming_guide/batched_rendering.html

To know more you will need to read the related pyglet code and be familiar
with
openGL.

So I guess putting text inside a batch is meaningless (looking through
> cocos.text.TextElement, I think I understood that pyglet uses a specific
> batch for each label).
>
> How can I add such a Sprite to a BatchNode ?
>
>
Forget batches while being new to cocos-pyglet.

Make a simple NamedSprite, beginning with something like

class NamedSprite(cocos.cocosnode.CocosNode):
    def __init__(self, name, *args, **kwargs):
        self.figure = cocos.sprite.Sprite(*args, **kwargs)
        self.label = cocos.text.Label(name)
        # adjust label position
        self.add(self.figure)
        self.add(self.label)

hth

claudio

--

-- 
You received this message because you are subscribed to the Google Groups 
"cocos2d discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cocos-discuss?hl=en.

Reply via email to