加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

cocos2d-x中 Box2D 加入debugDraw

发布时间:2020-12-14 19:24:50 所属栏目:百科 来源:网络整理
导读:1cocos2d中testcpp-box2dTestBed文件夹,下面有GLES-Render.h/GLES-Render.cpp,这两个文件先要拷到你的项目中 2在你的helloworldscene.h中创建GLESDebugDraw*m_DebugDraw对象再写个 voiddraw()方法 3在helloworldscene.cpp中init()函数里: //PTM_RATIO是bo
1cocos2d中testcpp->box2dTestBed文件夹,下面有GLES-Render.h/GLES-Render.cpp,这两个文件先要拷到你的项目中
2在你的helloworldscene.h中创建GLESDebugDraw*m_DebugDraw对象再写个 voiddraw()方法
3在helloworldscene.cpp中init()函数里:
//PTM_RATIO是box2d中单位米和像素转换比率#definePTM_RATIO32
m_DebugDraw=newGLESDebugDraw(PTM_RATIO);
//m_World是世界对象
m_World->SetDebugDraw(m_DebugDraw);
uint32flags=0;
flags+=b2Draw::e_shapeBit;
m_DebugDraw->SetFlags(flags);
draw();
4在helloworldscene.cpp中定义刚写的voiddraw()方法
voidHelloWorld::draw()
{
CCLayer::draw();

ccGLEnableVertexAttribs(kCCVertexAttribFlag_Position);
kmGLPushMatrix();
m_World->DrawDebugData();//这个是一定要写的其他几句不知道啥意思看别人代码抄的
kmGLPopMatrix();
CHECK_GL_ERROR_DEBUG();
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读