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

      <legend id='qC0qo'><style id='qC0qo'><dir id='qC0qo'><q id='qC0qo'></q></dir></style></legend>

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

      <tfoot id='qC0qo'></tfoot>
      • <bdo id='qC0qo'></bdo><ul id='qC0qo'></ul>

      box2d中不正确的碰撞

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

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

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

          • <tfoot id='oyk8x'></tfoot>

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

                问题描述

                限时送ChatGPT账号..

                我正在开发一款用户必须击打高速球的游戏.为了击球,我使用旋转关节连接了一个矩形体和演员,并启用了它的电机,以指定的速度(电机速度)旋转它.现在一切都很完美,但有时当球的速度很高时,它会绕过矩形体.使用碰撞侦听器,我发现正在发生碰撞,但球在碰撞后没有被反射.由于这种情况仅在球处于高速状态时才会发生,因此是否与碰撞的物体密度有关.还是负责它的旋转接头电机?我在这里错过了什么吗??

                I am developing a game in which the user have to hit a high speed ball. To hit the ball I have joined a rectangular body with the actor using revolute joint and enabled its motor, to rotate it with a specified speed(motor speed). Now everything is perfect but sometime when ball`s velocity is high , it is bypassing the rectagular body. Using collision listner i found that collision is happening but ball is not getting reflected after collision. As this is happening only when ball is on a high speed, is it bcoz of density of bodies that are colliding . Or its the motor of revolute joint that is responsible for it ?? Am i missing something here??

                这是两个主体的代码

                //矩形体的方法

                public Body createRectangleBodyPart(float x, float y, float width,
                        float height, short groupIndex) {
                    PolygonShape shape = new PolygonShape();
                    shape.setAsBox(width*WORLD_TO_BOX, height*WORLD_TO_BOX);
                    MassData massData = new MassData();
                    massData.mass = 15;
                    BodyDef bodyDef = new BodyDef();
                    bodyDef.type = BodyType.KinematicBody;
                    bodyDef.position.y = y*WORLD_TO_BOX;
                    bodyDef.position.x = x*WORLD_TO_BOX;
                     body = world.createBody(bodyDef);
                    body.setMassData(massData);
                    FixtureDef fixtureDef = new FixtureDef();
                    fixtureDef.shape = shape;
                    fixtureDef.density = 1;
                    fixtureDef.friction = 100f;
                    fixtureDef.restitution = 0.5f;
                    fixtureDef.filter.groupIndex=groupIndex;
                    body.createFixture(fixtureDef);
                    shape.dispose();
                    return body;
                }
                

                //球体方法

                    public Body createRoundBodyPart2(float x, float y, float radius,
                        short groupIndex, float density, int mass) {
                
                    CircleShape shape = new CircleShape();
                    shape.setPosition(new Vector2(0, 0));
                    shape.setRadius(radius*WORLD_TO_BOX ); // *18
                    BodyDef bodyDef = new BodyDef();
                    bodyDef.type = BodyType.DynamicBody;
                    bodyDef.position.y = y*WORLD_TO_BOX;
                    bodyDef.position.x = x*WORLD_TO_BOX;
                    MassData massData = new MassData();
                    massData.mass = 8;
                    Body body = world.createBody(bodyDef);
                    body.setMassData(massData);
                    FixtureDef fixtureDef = new FixtureDef();
                    fixtureDef.shape = shape;
                    fixtureDef.density = 0.5f;
                    fixtureDef.restitution=0.007f;
                    fixtureDef.filter.groupIndex = groupIndex;
                    body.createFixture(fixtureDef);
                    shape.dispose();
                    return body;
                }
                

                推荐答案

                尝试在你的球体上使用 isBullet=true 属性

                Try to use isBullet=true property on your ball body

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

                上一篇:将 libgdx 添​​加到 Android 原生应用程序 下一篇:将多个精灵旋转为一个(围绕同一原点)

                相关文章

                最新文章

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

                1. <tfoot id='6LdAH'></tfoot>
                    <bdo id='6LdAH'></bdo><ul id='6LdAH'></ul>
                2. <legend id='6LdAH'><style id='6LdAH'><dir id='6LdAH'><q id='6LdAH'></q></dir></style></legend>

                  <small id='6LdAH'></small><noframes id='6LdAH'>