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

  1. <legend id='Oc48K'><style id='Oc48K'><dir id='Oc48K'><q id='Oc48K'></q></dir></style></legend>

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

      Box2D 中的链形

      时间:2023-05-18
        <bdo id='vQIef'></bdo><ul id='vQIef'></ul>
        <legend id='vQIef'><style id='vQIef'><dir id='vQIef'><q id='vQIef'></q></dir></style></legend>

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

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

              • 本文介绍了Box2D 中的链形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..


                我最近开始学习 libgdx,但遇到了 Box2D 的 CainShape 的问题.


                I recently began to learn libgdx and I am stuck at a problem with the CainShape of Box2D.

                我的第一个目标是简单地创建一个带有 ChainShape 的盒子.

                My first goal is to simply create a box with a ChainShape.

                为了实现这一点,我将四个 Vector2 添加到一个数组中并使用它们创建一个循环.

                In order to achieve that, I added four Vector2 to an array and use them to create a loop.

                结果取决于阵列中的排列,要么是沙漏形的东西(左上角与右下角相连,右上角与左下角相连)或错误

                The result is depending on the arrangement in the array either an hourglass shaped thing (top left is connected with bottom right and top right is connected with bottom left) or the error

                表达式:b2DistanceSquared(v1, v2) > 0.005f * 0.005f

                Expression: b2DistanceSquared(v1, v2) > 0.005f * 0.005f

                这是我目前使用的代码:

                This is the code I used so far:

                Vector2[] box = new Vector2[4];
                
                    box[1] = new Vector2(0 -    bounds.getWidth() / 2 / Main.PPM, 0 -   bounds.getHeight() / 2 / Main.PPM);
                
                
                    box[0] = new Vector2(       bounds.getWidth() / 2 / Main.PPM, 0 -   bounds.getHeight() / 2 / Main.PPM);
                
                
                    box[2] = new Vector2(0 -    bounds.getWidth() / 2 / Main.PPM,       bounds.getHeight() / 2 / Main.PPM);
                
                
                    box[3] = new Vector2(       bounds.getWidth() / 2 / Main.PPM,       bounds.getHeight() / 2 / Main.PPM);
                
                    ChainShape chainShape = new ChainShape();
                    chainShape.createLoop(box);
                
                    fdef.shape = chainShape;
                    fixture = body.createFixture(fdef);
                

                我希望有人能告诉我我错过了什么.
                提前致谢!

                I hope somebody can tell me what I am missing.
                Thanks in advance!

                推荐答案

                调整您传递的参数并放入此代码中.这段代码肯定会跑

                Adjust the parameters you are passing and put in this code. This code will definitely run

                ChainShape chain = new ChainShape();
                
                createChain().Vec2[] vertices = new Vec2[2];
                vertices[0] = box2d.coordPixelsToWorld(0,150); 
                vertices[1] = box2d.coordPixelsToWorld(width,150);
                chain.createChain(vertices, vertices.length);
                
                FixtureDef fd = new FixtureDef();
                fd.shape = chain; 
                fd.density = 1;
                fd.friction = 0.3;
                fd.restitution = 0.5;
                body.createFixture(fd);
                

                希望这能回答这个问题,如果不是,请询问.

                Hope this answers the question if not please ask.

                这篇关于Box2D 中的链形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:LibGDX - 如何让我的菜单屏幕切换到游戏屏幕? 下一篇:矩形内的 libgdx 动画 - 碰撞检测 - 矩形

                相关文章

                最新文章

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

                  <tfoot id='cNLfQ'></tfoot>

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

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