• <small id='Ej5nc'></small><noframes id='Ej5nc'>

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

        <bdo id='Ej5nc'></bdo><ul id='Ej5nc'></ul>

        在 libgdx 中,如何在矩形顶部附加圆形?

        时间:2023-05-20
        <tfoot id='biXqw'></tfoot>
        <i id='biXqw'><tr id='biXqw'><dt id='biXqw'><q id='biXqw'><span id='biXqw'><b id='biXqw'><form id='biXqw'><ins id='biXqw'></ins><ul id='biXqw'></ul><sub id='biXqw'></sub></form><legend id='biXqw'></legend><bdo id='biXqw'><pre id='biXqw'><center id='biXqw'></center></pre></bdo></b><th id='biXqw'></th></span></q></dt></tr></i><div id='biXqw'><tfoot id='biXqw'></tfoot><dl id='biXqw'><fieldset id='biXqw'></fieldset></dl></div>

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

          <tbody id='biXqw'></tbody>

          • <bdo id='biXqw'></bdo><ul id='biXqw'></ul>
            <legend id='biXqw'><style id='biXqw'><dir id='biXqw'><q id='biXqw'></q></dir></style></legend>

                1. 本文介绍了在 libgdx 中,如何在矩形顶部附加圆形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我创建了一个主体,并创建了两个单独的夹具,一个夹具创建一个矩形,另一个夹具创建一个圆形.但是当我使用 .createfixture 时,它​​会将圆圈放在矩形的中心,我希望圆圈像火柴一样位于矩形的顶部.

                  I have created a body and I have created two separate fixtures, one fixture creates a rectangle shape and the other fixture creates a circle shape. But when I use the .createfixture it puts the circle in the centre of the rectangle, I want the circle on top of the rectangle like a matchstick.

                  这是我的代码不知道该怎么做...

                  here is my code don't know what to do ...

                  rectangleBodyDef = new BodyDef();
                  rectangleBodyDef.type = BodyType.DynamicBody;
                  rectangleBodyDef.position.set(10,20);
                  rectangleBody = world.createBody(rectangleBodyDef);
                  rectangleBodyShape = new PolygonShape();
                  rectangleBodyShape.setAsBox(2f, 0.75f);
                  rectangleBodyFixtureDef = new FixtureDef();
                  rectangleBodyFixtureDef.shape = rectangleBodyShape;
                  rectangleBodyFixtureDef.restitution = 0.8f;
                  rectangleBody.createFixture(rectangleBodyFixtureDef);
                  
                  
                  /**********************CREATING THE SECOND BODY (CIRCLE BODY) ************/
                  
                  
                  circleShape = new CircleShape();
                  circleShape.setRadius(0.75f);
                  circleFixtureDef = new FixtureDef();
                  circleFixtureDef.shape = circleShape;
                  circleFixtureDef.restitution = 0.8f;
                  rectangleBody.createFixture(circleFixtureDef);
                  

                  推荐答案

                  Fixture Definitions 是相对于身体位置的,设置 CircleShape 位置在矩形上方一点:

                  Fixture Definitions are relative to the body position, set the CircleShape position to be a little above the rectangle one:

                  CircleShape circleShape = new CircleShape();
                  circleShape.setRadius(0.75f);
                  
                  circleShape.setPosition(new Vector2(0,2));   //<------Add this
                  
                  FixtureDef circleFixtureDef = new FixtureDef();
                  circleFixtureDef.shape = circleShape;
                  circleFixtureDef.restitution = 0.8f;
                  rectangleBody.createFixture(circleFixtureDef);
                  

                  这篇关于在 libgdx 中,如何在矩形顶部附加圆形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何在 LibGDX 项目中显示插页式广告? 下一篇:文本字段 libgdx 中的字体大小

                  相关文章

                  最新文章

                2. <small id='iBfkM'></small><noframes id='iBfkM'>

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