1. Find the document: cocos2d-x and GLES-Render.h in the corresponding GLES-Render.cpp inventory
Copy them to your project and reference them;
2. Add these when creating the world
GLESDebugDraw * _ debugDraw = new GLESDebugDraw (PTM_RATIO );
World-> SetDebugDraw (_ debugDraw );
Uint32 flags = 0;
Flags + = b2Draw: e_shapeBit;
Flags + = b2Draw: e_jointBit;
Flags + = b2Draw: e_aabbBit;
Flags + = b2Draw: e_pairBit;
Flags + = b2Draw: e_centerOfMassBit;
_ DebugDraw-> SetFlags (flags );
3. Add or modify the draw Method
Void PlayLayer: draw ()
{
//
// IMPORTANT:
// This is only for debug purposes
// It is recommend to disable it
CCLayer: draw ();
Ccglablevertexattribs (kCCVertexAttribFlag_Position );
KmGLPushMatrix ();
World-> DrawDebugData ();
KmGLPopMatrix ();
CHECK_GL_ERROR_DEBUG ();
}
4. Do not set the background color or the image to keep the background black during debugging. Otherwise, it will be hard to see the deug box.