On Fri, Oct 24, 2008 at 12:55 PM, dexters <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I would like to display thumbnails of pictures lying on a virtual
> table in various shapes and forms. The user should be able to select
> one picture by clicking on it's visible part. The picture should then
> move to the top of the picture-stack, meaning that it will lie on top
> of all the other pictures.
>
> How could I efficiently handle all the various z-values for the
> different sprites? In theorie I would have to set the selected picture
> to z=max and move all others 'down'.
>
> Does one of you know how to handle the following problem in an
> efficient way?
>
Right now in cocos we are using a list of int, child for the children of a node.
#: list of children. each item is (int, child-reference) where int is
the z-order
self.children = []
When you add a child, its actually insort'ed into that list to respect
the z-ordering.
def add(self, child, z=0, name=None ):
[...]
elem = z, child
bisect.insort( self.children, elem )
[...]
Rendering is then done like this:
First, render all the child nodes that have z<0 (in z order)
Then render the parent node.
Then render all the child nodes that have z>0 (in z order)
So its a bit complicated to be changing in an efficient manner the z
value of stuff. You could remove a node and re add it, or create a
function to manipulate the child list, but this grows with the number
of nodes you have.
What i think you should do is have a node that has the currently
selected image. And move that node around, changing its content, so it
always represents the image you have selected. when you dont want it
no more, just dont draw it.
Hope this helps.
Lucio.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---