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

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

        <legend id='uTDrK'><style id='uTDrK'><dir id='uTDrK'><q id='uTDrK'></q></dir></style></legend>
      1. <small id='uTDrK'></small><noframes id='uTDrK'>

        libgdx ScissorStack 未按预期工作

        时间:2023-05-19

        <small id='0so1j'></small><noframes id='0so1j'>

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

              <tfoot id='0so1j'></tfoot><legend id='0so1j'><style id='0so1j'><dir id='0so1j'><q id='0so1j'></q></dir></style></legend>

                  <tbody id='0so1j'></tbody>

                1. 本文介绍了libgdx ScissorStack 未按预期工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我正在尝试创建一个进度条",但剪辑似乎没有按我预期的方式工作.这是我做错了什么还是我误解了什么?

                  应该剪辑的 draw() 例程:

                   @Override公共无效绘制(SpriteBatch 批次,浮动 parentAlpha){矩形剪刀 = new Rectangle();矩形clipBounds = new Rectangle(getX(), getY(), getWidth() * 0.75f, getHeight());ScissorStack.calculateScissors(getStage().getCamera(),getStage().getGutterWidth(),getStage().getGutterHeight(),getStage().getCamera().viewportWidth,getStage().getCamera().viewportHeight,批处理.getTransformMatrix(),剪辑边界,剪刀);如果(ScissorStack.pushScissors(剪刀)){super.draw(batch, parentAlpha);ScissorStack.popScissors();}}}

                  因为 draw 调用可能 会导致刷新发生,您需要将 draw 调用保持在 active-scissor 区域内.您可能还需要在启动活动剪刀区域之前刷新或结束批处理,以防止在剪刀开始在活动剪刀区域内刷新之前排队的绘制调用.

                  I'm trying to create a "progress bar" of sorts but the clipping doesn't seem to work the way I expect it to. Is this something I am doing wrong or something I've misinterpreted?

                  The draw() routine that should clip:

                      @Override
                      public void draw(SpriteBatch batch, float parentAlpha) {
                          Rectangle scissors = new Rectangle();
                          Rectangle clipBounds = new Rectangle(getX(), getY(), getWidth() * 0.75f, getHeight());
                  
                          ScissorStack.calculateScissors(
                                  getStage().getCamera(),
                                  getStage().getGutterWidth(),
                                  getStage().getGutterHeight(),
                                  getStage().getCamera().viewportWidth,
                                  getStage().getCamera().viewportHeight,
                                  batch.getTransformMatrix(),
                                  clipBounds, scissors);
                  
                          if (ScissorStack.pushScissors(scissors)) {
                              super.draw(batch, parentAlpha);
                              ScissorStack.popScissors();
                          }
                      }
                  }
                  

                  Complete sample code for ClipTest group class, TestScreen and screenshot.

                  • ClipTest is a subclass of group used to demonstrate the "bug".
                  • ClipImage is a subclass of Image, which performs the clipping on draw().
                  • ClipTest has 2 images, background and foreground.

                  The background is a black image and it should always be the full size of the progress bar.

                  The foreground is a white image and it's width is clipped depending on the percentage of the bar.

                  The strange result I've found is that although the foreground is using the clipping class, the background image is the one actually clipped.

                  The expected result was created using photoshop (as I couldn't produce it via code).

                  Any idea what's wrong?

                  解决方案

                  Actual drawing doesn't happen until the Batch "flushes", its not the draw call you need to wrap, as that just queues up drawing to be done later.

                  You need to make sure the OpenGL draw calls happen between enabling and disabling your scissors, so add a flush after the draw. See https://github.com/libgdx/libgdx/wiki/Clipping,-with-the-use-of-scissorstack

                  Because a draw call might cause a flush to happen, you need to keep the draw calls inside the active-scissor region. You may also need to flush or end the batch before starting the active scissor region to prevent queued draw calls from before the scissor start getting flushed inside the active scissor region.

                  这篇关于libgdx ScissorStack 未按预期工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:LibGDX HelloWorld 项目在 Android 模拟器上运行时崩溃 下一篇:Libgdx 的世界单位

                  相关文章

                  最新文章

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

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

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