title: How to enable Box2d debug draw with Coco2d-x 3.0 beta 2
body: <p>How I should enable debug draw with Cocos2d-x 3.0? There are some codes that do that with cocos2d-x 2.0 but they don't even compile on Cocos2d-x. Unfortunately I am new to both cocos2d-x and Box2d and I don't know how to port them. That would be great if you would share the method how you draw shapes.</p>
  
  <p>EDIT: </p>
  
  <p>I have found this:</p>
  
  <p><a href="http://blog.csdn.net/tian2kong/article/details/20386213" rel="nofollow">http://blog.csdn.net/tian2kong/article/details/20386213</a></p>
  
  <p>I have overridden the <code>draw</code> method of my applications main <code>Layer</code> like this:</p>
  
  <pre><code>void HelloWorld::draw()
  {
      GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POSITION);
      kmGLPushMatrix();
      m_world-&gt;drawDebugData();
      kmGLPopMatrix();
  }
  </code></pre>
  
  <p>And also have done this:</p>
  
  <pre><code>GLESDebugDraw *debugDraw = new GLESDebugDraw(PTM_RATIO);
  m_world.SetDebugDraw(debugDraw);
  uint32 flags = 0;
  flags += b2Draw::e_shapeBit;
  /*
  flags += b2Draw::e_jointBit;
  flags += b2Draw::e_centerOfMassBit;
  flags += b2Draw::e_aabbBit;
  flags += b2Draw::e_pairBit;
  */
  debugDraw-&gt;SetFlags(flags);
  </code></pre>
  
  <p>And it worked! But when I addChild a sprite, the shapes stay blow my sprites. How to bring them front?</p>