Problem enabling DebugDraw for box2d

Hi,
I’m using cocos2d-2.1beta3-x-2.1.1 in iOS and android and now I’m trying to enable the GLESDebugDraw for box2d using Xcode but no debug data is shown in my cclayer. This is my code (both methods are called):

void ZSailingFieldLayer::draw()
{
  CCLayer::draw();
  ccGLEnableVertexAttribs(cocos2d::kCCVertexAttribFlag_Position);
  kmGLPushMatrix();
  m_world->DrawDebugData();
  kmGLPopMatrix();
  CHECK_GL_ERROR_DEBUG();
}

void ZSailingFieldLayer::createWorld()
{
  // create world
  b2Vec2 gravity;
  gravity.Set(0.0f, 0.0f);
  m_world = new b2World(gravity);
  m_world->SetAllowSleeping(true);
  m_world->SetContinuousPhysics(true);

  // Debug Draw functions
  m_debugDraw = new GLESDebugDraw( ZConfig::ptmRatio() * cocos2d::CCDirector::sharedDirector()->getContentScaleFactor());
  m_world->SetDebugDraw(m_debugDraw);
  uint32 flags = 0;
  flags += b2Draw::e_shapeBit;
  flags += b2Draw::e_jointBit;
  flags += b2Draw::e_aabbBit;
  flags += b2Draw::e_pairBit;
  flags += b2Draw::e_centerOfMassBit;
  m_debugDraw->SetFlags(flags);
}

Any suggestion?

Note: I’ve compared my code with that in Box2dTest.cpp in the project TestCpp but there is no difference. I tried to execute the TestCpp example enabling box2d compilation but I’ve a compile error for a missing method: setCPBody for CCPhysicsSprite.

Thanks.
Giannandrea

Hi,
I’ve found out that debug data of box2d are behind my tiled map and sprites. What should I do to have box2d debug data in front of them? Now I’m going to change the z order of my stuff, I hope it enough.

Giannandrea

Giannandrea Castaldi wrote:

Hi,
I’m using cocos2d-2.1beta3-x-2.1.1 in iOS and android and now I’m trying to enable the GLESDebugDraw for box2d using Xcode but no debug data is shown in my cclayer. This is my code (both methods are called):
>
[…]
>
Any suggestion?
>
Note: I’ve compared my code with that in Box2dTest.cpp in the project TestCpp but there is no difference. I tried to execute the TestCpp example enabling box2d compilation but I’ve a compile error for a missing method: setCPBody for CCPhysicsSprite.
>
>
Thanks.
Giannandrea

I solved the problem using B2DebugDraw (https://github.com/vinova/B2DebugDraw), very useful :).

Giannandrea

Giannandrea Castaldi wrote:

Hi,
I’ve found out that debug data of box2d are behind my tiled map and sprites. What should I do to have box2d debug data in front of them? Now I’m going to change the z order of my stuff, I hope it enough.
>
Giannandrea
>
Giannandrea Castaldi wrote:
> Hi,
> I’m using cocos2d-2.1beta3-x-2.1.1 in iOS and android and now I’m trying to enable the GLESDebugDraw for box2d using Xcode but no debug data is shown in my cclayer. This is my code (both methods are called):
>
> […]
>
> Any suggestion?
>
> Note: I’ve compared my code with that in Box2dTest.cpp in the project TestCpp but there is no difference. I tried to execute the TestCpp example enabling box2d compilation but I’ve a compile error for a missing method: setCPBody for CCPhysicsSprite.
>
>
> Thanks.
> Giannandrea