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

        Libgdx Orthographic Camera 初始位置

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

          <tbody id='hO3i3'></tbody>

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

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

            <i id='hO3i3'><tr id='hO3i3'><dt id='hO3i3'><q id='hO3i3'><span id='hO3i3'><b id='hO3i3'><form id='hO3i3'><ins id='hO3i3'></ins><ul id='hO3i3'></ul><sub id='hO3i3'></sub></form><legend id='hO3i3'></legend><bdo id='hO3i3'><pre id='hO3i3'><center id='hO3i3'></center></pre></bdo></b><th id='hO3i3'></th></span></q></dt></tr></i><div id='hO3i3'><tfoot id='hO3i3'></tfoot><dl id='hO3i3'><fieldset id='hO3i3'></fieldset></dl></div>
                  <bdo id='hO3i3'></bdo><ul id='hO3i3'></ul>
                • 本文介绍了Libgdx Orthographic Camera 初始位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我希望正确定位相机,但我得到以下结果:

                  I would like the camera to be positioned correctly but I am getting the result below:

                  似乎当我调整窗口大小时,地图没有正确渲染.为什么会这样?

                  It seems like when I resize the window, the map does not get rendered properly. Why does that happen?

                  代码:

                  public void render(float delta){
                      Gdx.gl.glClearColor(0, 0, 0, 1);
                      Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
                  
                      camera.update();
                      mapRenderer.setView(camera);
                      mapRenderer.render(background);
                      mapRenderer.render(foreground);
                      shapeRenderer.setProjectionMatrix(camera.combined);
                  
                      //draw rectangles around walls
                      for(MapObject object : tiledMap.getLayers().get("walls").getObjects()){
                          if(object instanceof RectangleMapObject) {
                              RectangleMapObject rectObject = (RectangleMapObject) object;
                              Rectangle rect = rectObject.getRectangle();
                              shapeRenderer.begin(ShapeType.Line);
                              shapeRenderer.rect(rect.x, rect.y, rect.width, rect.height);
                              shapeRenderer.end();
                          }
                      }
                      //done drawing rectangles
                  }
                  
                  @Override
                  public void resize(int width, int height) {
                      camera.viewportWidth = width;
                      camera.viewportHeight = height;
                  }
                  
                  @Override
                  public void show(){
                      //call the tile map here
                      //I believe this is called first before render() is called
                      tiledMap = new TmxMapLoader().load("data/mapComplete.tmx");
                      mapRenderer = new OrthogonalTiledMapRenderer(tiledMap, 1f);
                  
                      //initiate shapeRenderer. Can remove later
                      shapeRenderer = new ShapeRenderer();
                      shapeRenderer.setColor(Color.RED);
                  
                      camera = new OrthographicCamera();
                      camera.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
                  }
                  

                  推荐答案

                  这应该使 camera 在游戏的 viewport 居中.

                  This should center the camera at the viewport of the game.

                  @Override
                  public void resize(int width, int height) {
                      camera.viewportWidth = width;
                      camera.viewportHeight = height;
                      camera.position.set(width/2f, height/2f, 0); //by default camera position on (0,0,0)
                  }
                  

                  这篇关于Libgdx Orthographic Camera 初始位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:LibGDX FreeType 字体模糊 下一篇:libgdx- pixmap:我能以某种方式改变线条的宽度吗?

                  相关文章

                  最新文章

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

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

                      • <bdo id='xgYlb'></bdo><ul id='xgYlb'></ul>