I was going to ask how to hack a resizeable color layer, but I think I managed to patch it together just by guessing. I needed this for creating a visible box for in game selection.

class ResizeableCL(ColorLayer):

    # resize is called from on_mouse_drag
    def resize(self, dx, dy):
        self.width += dx
        self.height += dy

    def draw(self):
        x, y = self.width, self.height
        ox, oy = 0, 0
        self._vertex_list.delete()
        self._vertex_list = self._batch.add(4, pyglet.gl.GL_QUADS, None,
            ('v2i', ( ox, oy,
                      ox, oy + y,
                      ox+x, oy+y,
                      ox+x, oy)),
            'c4B')

        glPushMatrix()
        self.transform()
        glPushAttrib(GL_CURRENT_BIT)
        self._batch.draw()
        glPopAttrib()
        glPopMatrix()

It seems to work for me, looks good and responsive. Is it correct way of doing it?

--
You received this message because you are subscribed to the Google Groups "cocos2d 
discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cocos-discuss.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to