How to draw on just a portion of the screen with SpriteBatch in libgdx?

前端 未结 4 1574
-上瘾入骨i
-上瘾入骨i 2021-01-23 07:53

When I do this:

SpriteBatch spriteBatch = new SpriteBatch();
spriteBatch.setProjectionMatrix(new Matrix4().setToOrtho(         


        
4条回答
  •  遥遥无期
    2021-01-23 08:23

    Perhaps I am misunderstanding the question, but could you not just double the viewport width, setting it to 640 instead of 320?

    SpriteBatch spriteBatch = new SpriteBatch;
    spriteBatch.setProjectionMatrix(new Matrix4().setToOrtho(0, 640, 0, 240, -1, 1));
    spriteBatch.begin();
    spriteBatch.draw(textureRegion, 0, 0);
    spriteBatch.end();
    

提交回复
热议问题