Libgdx相机/缩放问题 [英] Libgdx camera/scaling issue
本文介绍了Libgdx相机/缩放问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这只是一个真正的快速的帖子想知道我做错了什么?
This is just a really quick post wondering what i have done wrong?
我想要的背景填充在整个屏幕上,这不使它工作。 这里是所有的代码:
I want the background to be filled on the whole screen with whatever screen sizes i have but this does not make it work. Here is all the code:
// 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();
}
:)
推荐答案
问题是你的资源与视口大小不一样。请参阅下面的链接。 Libgdx使用Viewport类来处理这个。
The problem is your asset is not the same size as the viewport. See the links below. Libgdx uses the Viewport class to handle this.
https://github.com/libgdx/libgdx/wiki/视口
这篇关于Libgdx相机/缩放问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文