Ios box2d调试绘图不工作

Ios box2d调试绘图不工作,ios,cocos2d-iphone,box2d,Ios,Cocos2d Iphone,Box2d,我试图在一个IOS项目中使用box2d的调试绘图,使用看起来正确的代码,但屏幕上没有显示任何内容。代码如下: b2Vec2 gravity = b2Vec2(0.0f, 0.0f); _world = new b2World(gravity); _world->SetContinuousPhysics(true); m_debugDraw = new GLESDebugDraw( PTM_RATIO ); _world->SetDebugDraw(m_debugDraw); uint

我试图在一个IOS项目中使用box2d的调试绘图,使用看起来正确的代码,但屏幕上没有显示任何内容。代码如下:

b2Vec2 gravity = b2Vec2(0.0f, 0.0f);
_world = new b2World(gravity);
_world->SetContinuousPhysics(true);
m_debugDraw = new GLESDebugDraw( PTM_RATIO );
_world->SetDebugDraw(m_debugDraw);
uint32 flags = 0;
flags += b2Draw::e_shapeBit;
flags += b2Draw::e_jointBit;
flags += b2Draw::e_centerOfMassBit;
flags += b2Draw::e_aabbBit;
flags += b2Draw::e_pairBit;
m_debugDraw->SetFlags(flags);

我错过了什么

您必须覆盖draw方法

- (void) draw
{
    [super draw];
    ccGLEnableVertexAttribs(kCCVertexAttribFlag_Position);
    kmGLPushMatrix();
    world->DrawDebugData();
    kmGLPopMatrix();
}

约翰·华兹华斯在这里提出的解决方案对我来说非常有效

谢谢@Martin。我应该包括一些类,以便ccGLEnableVertexAttribs(kCCVertexAttribFlag_Position)和kmGLPushMatrix编译吗?您需要包括GLES Render。我仍然得到“使用未声明标识符kCCVertexAttribFlag_Position”,并且编译器还提供用glPushMatrix(和pop)替换kmGLPushMatrix(和pop)所以只有第一个错误仍然存在。是否也包含“cocos2d.h”?我正在使用Kobold2D,它可能包含一些我不知道的文件。你说得对。无论如何,这是你自己发现的,所以你不必接受我的答案。