Skip to content

Commit cfee1db

Browse files
committed
Scale background from menu screen proportionally.
1 parent 5f0a0dd commit cfee1db

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

blade-engine/src/com/bladecoder/engine/ui/MenuScreen.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,13 @@ public void show() {
114114
if (bg == null && style.bgFile != null) {
115115
bgTexFile = new Texture(EngineAssetManager.getInstance().getResAsset(style.bgFile));
116116
bgTexFile.setFilter(TextureFilter.Linear, TextureFilter.Linear);
117+
118+
float scale = (float)bgTexFile.getHeight() / (float) stage.getViewport().getScreenHeight();
119+
120+
int width = (int)(stage.getViewport().getScreenWidth() * scale);
121+
int x0 = (int)((bgTexFile.getWidth() - width) / 2);
117122

118-
bg = new TextureRegionDrawable(new TextureRegion(bgTexFile));
123+
bg = new TextureRegionDrawable(new TextureRegion(bgTexFile, x0, 0, width, bgTexFile.getHeight()));
119124
}
120125

121126
menuButtonTable.clear();

0 commit comments

Comments
 (0)