Cocos2d-x--Box2D使用GLES-Render.h渲染查看刚体

分为两部分:文件拷贝和代码实现html

 

1.文件拷贝:ide

 

在TestCpp下找到GLES-Render.h和GLES-Render.cpp两个文件ui

Box2D

复制到G:\cocos2d-2.1rc0-x-2.1.3\cocos2d-2.1rc0-x-2.1.3\cocos2dx\platform\win32下debug

Cocos2d

 

 

工程中也要有一份orm

Box2D

 

 

2.代码实现:htm

添加引用:#include <GLES-Render.h>it

 

建立世界的时候加上这些

io

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);


 

添加或者修改 draw 方法

form

void HelloWorld::draw()
{
CCLayer::draw();

ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position );

kmGLPushMatrix();

world->DrawDebugData();

kmGLPopMatrix();

CHECK_GL_ERROR_DEBUG();
}
相关文章
相关标签/搜索