I'm trying to understand how to create z-order system like you can see in http://www.realmofthemadgod.com/
Character is above the tree when he is in front of it and vice versa.
Also, I'm planning to use sprite batching and all the sprites will not fit in one texture (2048*2048 for cocos2d-iphone). So I need to use several batches (like one for background and one for characters).
Additional "top-background" layer with above the character layer will not solve the problem: what if two characters are staying in front and behind a tree at the same time?
So, I'm thinking about some sort of masking but I don't know how to properly implement it.
Example from the RotMG: http://i.stack.imgur.com/d8dAe.png