I have problems drawing a box. I’m using coco2d + box2d (latest versions) in c++. Anyone know how can I view exactly the box that box2d is drawing? if I declare this:
b2PolygonShape bps; bps.SetAsBox(2/SCALE_RATIO, 2/SCALE_RATIO);
When another object collides with the box, I have some idea that limits of the box. But how can I view in the screen the 4 lines box that box2d is drawing?
I read about GLES-Render for debug drawing. This should help me? I tried follow this steps:
I downloaded this file: http://discuss.cocos2d-x.org/uploads/default/12747/1d511bac2a477efb.zip
I added the .h and .cpp files to my project.
I added this method to my Scene class:
void GameManager::draw(Renderer renderer, const Mat4 &transform, uint32_t flags)
GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION );
Director director = Director::getInstance();
CCASSERT(nullptr != director, “Director is null when seting matrix stack”);
In my GameManager class, in the Constructor, when I create the scene, I added:
scene->addChild(B2DebugDrawLayer::create(_world, SCALE_RATIO), 99);
After that, I run the program and it’s not compile. It failed with 2 errors:
Apple Mach-O Linker (ld) Error Group "B2DebugDrawLayer::create(b2World*, float)", referenced from: clang: error: linker command failed with exit code 1 (use -v to see invocation)
I tested another GLES-Render classes and some compiles work fine but I don’t view the 4 box line that box2d is drawing. Anyone have any example that works in the last versions? Adding the layer child should be sufficient ? or I should be edit other part of my code?