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

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

        libgdx - Group.draw 中的 ShapeRenderer 以错误的颜色呈现

        时间:2023-05-19
      1. <tfoot id='1Yk8o'></tfoot>

        • <small id='1Yk8o'></small><noframes id='1Yk8o'>

              <tbody id='1Yk8o'></tbody>

                <bdo id='1Yk8o'></bdo><ul id='1Yk8o'></ul>
                <i id='1Yk8o'><tr id='1Yk8o'><dt id='1Yk8o'><q id='1Yk8o'><span id='1Yk8o'><b id='1Yk8o'><form id='1Yk8o'><ins id='1Yk8o'></ins><ul id='1Yk8o'></ul><sub id='1Yk8o'></sub></form><legend id='1Yk8o'></legend><bdo id='1Yk8o'><pre id='1Yk8o'><center id='1Yk8o'></center></pre></bdo></b><th id='1Yk8o'></th></span></q></dt></tr></i><div id='1Yk8o'><tfoot id='1Yk8o'></tfoot><dl id='1Yk8o'><fieldset id='1Yk8o'></fieldset></dl></div>
                  <legend id='1Yk8o'><style id='1Yk8o'><dir id='1Yk8o'><q id='1Yk8o'></q></dir></style></legend>
                  本文介绍了libgdx - Group.draw 中的 ShapeRenderer 以错误的颜色呈现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我的群组:

                  public class GShape extends Group{
                  private ShapeRenderer shape;
                  
                  public GShape() {
                      super();
                      shape = new ShapeRenderer();
                  }
                  
                  @Override
                  public void draw(SpriteBatch batch, float parentAlpha) {
                      super.draw(batch, parentAlpha);
                      shape.begin(ShapeType.Line);
                      Gdx.gl10.glLineWidth(5);
                      shape.setColor(1, 1f, 1f, 1f);
                      shape.line(0, 0, 200, 100);
                      shape.end();
                  }
                  }
                  

                  主要:

                  public class GameControl implements ApplicationListener {
                  private Stage stage;
                  private GShape gShape;
                  
                  @Override
                  public void create() {
                      stage = new Stage(480,320,false);
                  
                      Texture t = new Texture(Gdx.files.internal("data/the200.png"));
                      Image i = new Image(t);
                      stage.addActor(i);
                      gShape = new GShape();
                      stage.addActor(gShape);
                  }
                  
                  @Override
                  public void dispose() {
                  }
                  
                  @Override
                  public void render() {
                      Gdx.gl.glClearColor(0, 0, 0, 1);
                      Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
                      stage.draw();
                  //  gShape.render();
                  }
                  
                  @Override
                  public void resize(int width, int height) {
                  }
                  
                  @Override
                  public void pause() {
                  }
                  
                  @Override
                  public void resume() {
                  }
                  } 
                  

                  形状的颜色不是白色?为什么?

                  Colour of shape is not white? Why?

                  http://nw7.upanh.com/b3.s38.d3/352dd792eb77ce6df204a7af47ae1ac6_55348087.cos.jpg?rand=0.19125773780979216

                  推荐答案

                  您可能会得到不一致的结果,因为您混合了 SpriteBatchShapeRenderer 上下文.这两个都希望在 begin()end() 调用之间维护它们存储"在 OpenGL 中的状态.

                  You are probably getting inconsistent results because you're mixing SpriteBatch and ShapeRenderer contexts. Both of these expect state they "store" in OpenGL to be maintained between begin() and end() calls.

                  Actor draw() 方法在 SpriteBatch begin() 已经存在的上下文中调用已被调用,因此您需要在开始 ShapeRenderer 之前结束它.(并且您需要在返回之前重新启动SpriteBatch.

                  The Actor draw() method is called in a context where the SpriteBatch begin() has already been called, so you need to end it before beginning your ShapeRenderer. (And you need to restart the SpriteBatch before returning.

                  像这样:

                  @Override
                  public void draw(SpriteBatch batch, float parentAlpha) {
                    super.draw(batch, parentAlpha);
                    batch.end();   //  ** End the batch context
                    shape.begin(ShapeType.Line);
                    // .. draw lines ...
                    shape.end()
                    batch.begin(); // ** Restart SpriteBatch context that caller assumes is active
                  }
                  

                  这篇关于libgdx - Group.draw 中的 ShapeRenderer 以错误的颜色呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:使用 ScreenUtils 将屏幕截图保存为 libgdx 中的图像 下一篇:Java LibGDX 如何解析 JSON?

                  相关文章

                  最新文章

                  <tfoot id='KqSzS'></tfoot>

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

                        <bdo id='KqSzS'></bdo><ul id='KqSzS'></ul>
                    2. <small id='KqSzS'></small><noframes id='KqSzS'>