cocos2d draw polys over background - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: iPhone, iPad & iPod Game Development (/forum-11.html)
+--- Thread: cocos2d draw polys over background (/thread-8471.html)
cocos2d draw polys over background - aerospaceman - Dec 28, 2010 07:04 PM
I added a background in my scene init,as a sprite. I'm drawing my game elements as polygons: ccDrawPoly. But the background appears on top of my polys which are thus rendered invisible.
Is there a way to get around this and show my polygons over the background?
RE: cocos2d draw polys over background - Skorche - Dec 28, 2010 07:27 PM
Put the draw calls in a node that has a z order higher than the background.
RE: cocos2d draw polys over background - Sumaleth - Dec 28, 2010 07:56 PM
Or reverse the order you draw the polygons. Or disable GL_DEPTH_TEST (if its enabled).
RE: cocos2d draw polys over background - aerospaceman - Dec 29, 2010 10:23 AM
I figured it out!
the background has to be added with z of -1.
I think the draw method has a z of 0 by default. (I couldn't figure out how to increase the z of the objects drawn with draw.)
RE: cocos2d draw polys over background - Skorche - Dec 29, 2010 11:56 AM
Yes, the draw method is effectively called with a z of 0 and you can't change it. You can trigger the drawing from a subnode if you need more control over draw order.