• <legend id='BT15I'><style id='BT15I'><dir id='BT15I'><q id='BT15I'></q></dir></style></legend>

    • <bdo id='BT15I'></bdo><ul id='BT15I'></ul>

        <small id='BT15I'></small><noframes id='BT15I'>

        <tfoot id='BT15I'></tfoot>
      1. <i id='BT15I'><tr id='BT15I'><dt id='BT15I'><q id='BT15I'><span id='BT15I'><b id='BT15I'><form id='BT15I'><ins id='BT15I'></ins><ul id='BT15I'></ul><sub id='BT15I'></sub></form><legend id='BT15I'></legend><bdo id='BT15I'><pre id='BT15I'><center id='BT15I'></center></pre></bdo></b><th id='BT15I'></th></span></q></dt></tr></i><div id='BT15I'><tfoot id='BT15I'></tfoot><dl id='BT15I'><fieldset id='BT15I'></fieldset></dl></div>
      2. Cocos2d + Box2d - 如何调试/显示身体?

        时间:2024-08-11

        • <i id='8njTa'><tr id='8njTa'><dt id='8njTa'><q id='8njTa'><span id='8njTa'><b id='8njTa'><form id='8njTa'><ins id='8njTa'></ins><ul id='8njTa'></ul><sub id='8njTa'></sub></form><legend id='8njTa'></legend><bdo id='8njTa'><pre id='8njTa'><center id='8njTa'></center></pre></bdo></b><th id='8njTa'></th></span></q></dt></tr></i><div id='8njTa'><tfoot id='8njTa'></tfoot><dl id='8njTa'><fieldset id='8njTa'></fieldset></dl></div>
            <tbody id='8njTa'></tbody>
          <tfoot id='8njTa'></tfoot>

          1. <legend id='8njTa'><style id='8njTa'><dir id='8njTa'><q id='8njTa'></q></dir></style></legend>
              <bdo id='8njTa'></bdo><ul id='8njTa'></ul>

              • <small id='8njTa'></small><noframes id='8njTa'>

                  本文介绍了Cocos2d + Box2d - 如何调试/显示身体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我使用 Cocos2d (2.0) 和随附的 Box2d 创建了一个非常简单的设置.我的世界中有一些实体,但还没有与它们关联的精灵,我想调试它们的方向、位置等.

                  I've created a pretty simple setup using Cocos2d (2.0) and Box2d that comes packaged with it. I have a few bodies in my world, but don't have sprites linked up with them yet and I want to debug their orientations, positions, etc.

                  这似乎是一项非常标准的任务,但我不知道如何轻松地做到这一点.根据我的研究,它似乎与这些方法有关:

                  This seems like a pretty standard task, but I could not find out how to do this easily. From my research it seems related to these methods:

                  _world->SetDebugDraw(...);
                  _world->DrawDebugData(...);
                  // and the GLES-Render class
                  

                  帮助?

                  推荐答案

                  我想出来以防万一其他人偶然发现.

                  I figured it out in case anyone else stumbles across this.

                  1. 在您的初始化中,您要创建一个调试绘图对象(GLESDebugDraw 自带 Cocos2d+Box2d).
                  2. 设置标志以指定您想要绘制的内容(形状、重心、关节等).
                  3. 将其分配给您的世界对象.

                  b2Draw *debugDraw = new GLESDebugDraw(PTM_RATIO);

                  debugDraw->SetFlags(GLESDebugDraw::e_shapeBit);

                  _world->SetDebugDraw(debugDraw);

                  那么,诀窍就是你需要重写ccLayer的draw方法并调用:

                  Then, the trick is that you need to override ccLayer's draw method and call:

                  _world->DrawDebugData();

                  它必须在 draw 方法中,否则这将不起作用.我最初尝试将它放在我自己的预定方法中(我在其中调用 _world->step()),但这没有用.

                  It must be in the draw method otherwise this won't work. I initially tried to put it in my own scheduled method (where I call _world->step()) and this did not work.

                  这篇关于Cocos2d + Box2d - 如何调试/显示身体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何在cocos 2D中的某个时间段内查找视图是否被点击超过2次 下一篇:滑动精灵时,如果精灵从一侧消失,它会绕到对面吗?

                  相关文章

                  • <bdo id='xgH5V'></bdo><ul id='xgH5V'></ul>

                  1. <small id='xgH5V'></small><noframes id='xgH5V'>

                    <tfoot id='xgH5V'></tfoot>
                    <legend id='xgH5V'><style id='xgH5V'><dir id='xgH5V'><q id='xgH5V'></q></dir></style></legend>
                  2. <i id='xgH5V'><tr id='xgH5V'><dt id='xgH5V'><q id='xgH5V'><span id='xgH5V'><b id='xgH5V'><form id='xgH5V'><ins id='xgH5V'></ins><ul id='xgH5V'></ul><sub id='xgH5V'></sub></form><legend id='xgH5V'></legend><bdo id='xgH5V'><pre id='xgH5V'><center id='xgH5V'></center></pre></bdo></b><th id='xgH5V'></th></span></q></dt></tr></i><div id='xgH5V'><tfoot id='xgH5V'></tfoot><dl id='xgH5V'><fieldset id='xgH5V'></fieldset></dl></div>