0
我遇到了一個問題,讓我的圖像填充整個屏幕而不伸展自己。目前我有一個正交相機設置,但問題是屏幕中間的圖像顯示的原點(0,0)。我該如何做這項工作?這是我的代碼。LibGDX - 我的圖像沒有填充屏幕的寬度和高度
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();
}