【发布时间】:2014-09-02 01:43:52
【问题描述】:
我无法让我的图像填满整个屏幕而不拉伸自身。目前我有一个正交相机设置,但问题是屏幕中间显示的图像的原点(0,0)。我怎样才能使这项工作?这是我的代码。
public class GameScreen implements Screen {
SlingshotSteve game;
public void Menu(SlingshotSteve game){
this.game = game;
}
OrthographicCamera camera;
SpriteBatch batch;
TextureRegion backgroundTexture;
Texture texture;
GameScreen(final SlingshotSteve gam) {
this.game = gam;
camera = new OrthographicCamera(800, 480);
batch = new SpriteBatch();
Texture texture = new Texture(Gdx.files.internal("background.jpg"));
backgroundTexture = new TextureRegion(texture, 0, 0, 500, 500);
}
public void render(float delta) {
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
camera.update();
batch.setProjectionMatrix(camera.combined);
batch.begin();
batch.draw(backgroundTexture, 0, 0, SlingshotSteve.WIDTH, SlingshotSteve.HEIGHT);
batch.end();
}
@Override
public void dispose() {
batch.dispose();
texture.dispose();
}
【问题讨论】: