所以我創建了一個遊戲,我將繪製一個背景,但是這個背景並沒有覆蓋整個屏幕,即使當我降低窗口大小時,它也沒有覆蓋整個窗口。下面是繪製背景的代碼:Libgdx縮放背景問題
Gdx.gl20.glClearColor(0.2F, 0.6F, 1F, 1F);
Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT);
cam.update();
sb.setProjectionMatrix(cam.combined);
sb.begin();
sb.draw(Assets.splash_spr_background, 0, 0);
sb.end();
,這裏是初始化精靈代碼:
public static Texture splash_tex_background;
public static Sprite splash_spr_background;
public static void init()
{
splash_tex_background = new Texture(Gdx.files.internal("Splash Screen/background.png"));
splash_tex_background.setFilter(TextureFilter.Linear, TextureFilter.Linear);
splash_spr_background = new Sprite(splash_tex_background);
}
最後在這裏被用於初始化相機& spritebatch東西代碼:
cam = new OrthographicCamera();
cam.setToOrtho(false, 1920, 1080);
sb = new SpriteBatch();
現在這是我的問題:爲什麼這不起作用?我做錯了什麼?
感謝您的幫助! :)
什麼大小你的background.png? – WeMakeSoftware
@Funtik它是1280 x 720,但我認爲它會縮放? – Dumbostyle
只有你告訴它(bg精靈)才能縮放。但更清潔的解決方案將是使用一個視口來管理你的相機大小,所以你不必隨着你的遊戲將有的每個其他精靈一起縮放你的背景。 – Tenfour04