[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] newbie question--> rendeing order



> the problem is that i would like to keep a hierarchy. the one clicked 
> goes aboveand the rest one step down.
> if this would be a list i would pop the clicked sprite and the append 
> it to the rendering queue so that its rendered the last one.
> 
> but this is not a list. its a group, and i am not sure that the order of 
> the group affects the rendering order.

I believe (although it's not documented) that one should assume that all
sprites in a group have a random ordering within that group, and it is
not recommended to try to sort them in any way.

What you're trying to do is create layers for sprites (also known as a
z-axis property for sprites).  The common way to do this with the Pygame
Sprite and SpriteGroup classes is to have multiple groups, and draw()
them in a consistent order -- the last group drawn is on top.

Check out MonkeyStomp in the Gamelets section for an example -- it's
like ChimpLineByLine taken to the next level.

-sjbrown

-- 
+-------------------------------------------------------------+
| Shandy Brown                               Digital Thinkery |
| shandy@geeky.net             http://www.digitalthinkery.com |
+-------------------------------------------------------------+