这只是一个非常快速的帖子,想知道我做错了什么?
我希望在整个屏幕上使用我拥有的任何屏幕尺寸填充背景但这不会使其工作。 以下是所有代码:
// Variables
Jump game;
OrthographicCamera cam;
SpriteBatch sb;
// Variables
public SplashScreen(Jump game)
{
this.game = game;
cam = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
cam.translate(cam.viewportWidth / 2, cam.viewportHeight / 2);
sb = new SpriteBatch();
}
public void show()
{
}
public void render(float delta)
{
Gdx.gl20.glClearColor(0.2F, 0.6F, 1F, 1F);
Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT);
cam.update();
sb.begin();
sb.setProjectionMatrix(cam.combined);
sb.draw(Assets.splash_spr_background, 0, 0);
sb.end();
}
谢谢! :)
答案 0 :(得分:3)
问题是您的资产与视口的大小不同。请参阅以下链接。 Libgdx使用Viewport类来处理这个问题。
How to deal with different aspect ratios in libGDX?
How to scale image according to different screen resolutions in libgdx