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

        覆盖绘图顺序scene2D的舞台

        时间:2023-05-19

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

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

              <tbody id='qSCc1'></tbody>

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

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

                  本文介绍了覆盖绘图顺序scene2D的舞台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  libgdx 中为您提供了一个复杂的 Scene2D 图,其中包含多个 Group'sActor's.您希望用户选择一些 Actors 并在最后绘制它们,以便它们看起来集中在任何其他 Actors 之上.

                  You are given a complex Scene2D graph in libgdx with several Group's and Actor's. You want the user to select some Actors and draw those at the end so they appear focussed on top of any other Actors.

                  我想迭代 Stage 两次.第一次绘制未选中的Actors,第二次绘制选中的actors.但是,我没有看到任何好的"方法来强制执行此行为.

                  I would like to iterate over the Stage twice. The first time it draws the unselected Actors, the second time it draws the selected actors. I don't see any 'good' way to enforce this behaviour however.

                  我更喜欢干净的选项.我不想为了这个小小的添加而复制整个方法实现.

                  I would prefer options that are clean. I would not like to copy an entire method implementation just for the sake of this small addition.

                  什么不起作用:

                  • Actor's toFront() 方法只适用于它的兄弟姐妹.
                  • 在舞台中交换 Actor's 的位置:这会修改 Actors 的转换.
                  • the Actor's toFront() method only works for it's siblings.
                  • swapping places of Actor's in the Stage: this modifies the transformations the Actors have.

                  需要考虑的场景:您有一个 Root,其中包含一个组 gA 和一个组 gB.Group gA 包含两个图像 iA1iA2.Group gB 包含一个图像 iB.假设 Group gA 首先添加到舞台,并且图像 iA1iB 重叠;现在您要选择 iA1 并使其出现在 iB 上.我不想只调用 gA.toFront();这会将整个 Group gA 放在前面,这意味着 iA2 也放在前面.将 iA2 放在前面有将部分图像隐藏在 Group gB

                  Scenario to think about: you have a Root with a group gA and a group gB. Group gA contains two images iA1 and iA2. Group gB contains one image iB. Given that Group gA is added first to the stage and that image iA1 overlaps with iB; now you want to select iA1 and make it appear over iB. I don't want to only call gA.toFront(); this would put the whole Group gA to the front, which means also iA2 is put to the front. Putting iA2 in front has the undesired effect of hiding parts of images inside Group gB

                  推荐答案

                  有两种解决方案-

                  1 - 停止使用 [多个] 组.糟透了,但这可能是更容易的选择.如果您查看渲染/绘图是如何完成的,您将从舞台的根组开始,并获取其子级并渲染它们.对于这些孩子中的每一个,如果它们是一个组,则呈现该组的孩子.ZIndex 只不过是一个组内的孩子的顺序.如果您查看 Actor 的 setZIndex,您就会明白为什么 toFrontsetZIndex 只影响兄弟姐妹.

                  1 - Stop using [multiple] groups. Sucks but this may be the easier option. If you look at how rendering/drawing is done you start at the root Group for a Stage and get its children and render them. For each of those children, if they are a Group then render that Groups children. ZIndex is nothing more than the order of children within a group. If you look at the Actor's setZIndex you can see why toFront or setZIndex only affect siblings.

                  public void setZIndex (int index) {
                      if (index < 0) 
                          throw new IllegalArgumentException("ZIndex cannot be < 0.");
                  
                      Group parent = this.parent;
                      if (parent == null) 
                          return;
                  
                      Array<Actor> children = parent.getChildren();
                      if (children.size == 1) 
                          return;
                  
                      if (!children.removeValue(this, true)) 
                          return;
                  
                      if (index >= children.size)
                          children.add(this);
                      else
                          children.insert(index, this);
                  }
                  

                  2 - 唯一的其他选择是更改所有演员的绘制顺序.您必须扩展 Stage 并根据您选择的不同顺序将 draw 方法替换为 draw.您可能必须合并 Group.drawChildren 方法中的许多功能.

                  2 - The only other option would be to change the drawing order of all the actors. You'd have to extend Stage and replace the draw method to draw based on a different order of your choosing. You'd probably have to incorporate a lot of the functionality from the Group.drawChildren method.

                  TLDR;LibGDX 中的实现方式 - 组是一个层.如果您不想要图层,请更改组的功能或停止使用组.

                  TLDR; The way things are implemented in LibGDX - a Group is a layer. If you don't want layers then either change what groups do or stop using groups.

                  这篇关于覆盖绘图顺序scene2D的舞台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:libgdx 中的多色文本 下一篇:使用 LibGDX Gdx.files.internal 加载 .png 文件时遇到问

                  相关文章

                  最新文章

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

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

                    <legend id='GcUHt'><style id='GcUHt'><dir id='GcUHt'><q id='GcUHt'></q></dir></style></legend>
                  2. <small id='GcUHt'></small><noframes id='GcUHt'>