cocos2d draw polys over background

Member
Posts: 60
Joined: 2009.06
Post: #1
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?
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #2
Put the draw calls in a node that has a z order higher than the background.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Apprentice
Posts: 14
Joined: 2010.01
Post: #3
Or reverse the order you draw the polygons. Or disable GL_DEPTH_TEST (if its enabled).
Quote this message in a reply
Member
Posts: 60
Joined: 2009.06
Post: #4
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.)
thanks everyone
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #5
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.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  How max polys/vertex can I use for a game? Eskema 3 2,586 Aug 4, 2009 09:42 AM
Last Post: Eskema
  OpenGL - how to draw background image? SDyer777 1 7,046 Mar 9, 2009 11:17 AM
Last Post: AnotherJake