Use of debugDraw in Cocos2d-x

Source: Internet
Author: User

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.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.