Why the background cover the LmlView
roleyzhang opened this issue · 4 comments
Hi,
I imitate the tutorial examples
Your-first-LML-application
created my testing project, and added a picture as background. but the background picture always covers my window elements. This is my code
@Override
public void render() {
super.render();
LoadingView.setProgress(assetManager.getProgress());
if (assetManager.update()) {
bg = assetManager.get("picture/bg1.jpg", Texture.class);
batch.begin();
batch.draw(bg, Gdx.graphics.getWidth() / 2 - cfg.getWIDTH() / 2, Gdx.graphics.getHeight() / 2 - cfg.getHEIGHT() / 2, cfg.getWIDTH(), cfg.getHEIGHT());
batch.end();
}
}
Is there any way to solve this problem? I try to set the background of the z-index, but do not know how to do. Please give me some advise. Thank you!
super.render();
is likely drawing the UI, so by calling it before batch.draw
, you're causing the background to be rendered after the interface. Try moving super.render()
to the end of the method.
Anyway, try using LML to render the background:
- Add the image to your skin atlas (e.g. with
"background"
region name). - Use
<image>
tag on top of your LML template before defining the UI:
<image style="background"/>
I edited your comment to add code formatting.
Thank you MJ
I'm assuming this fixed the problem. Feel free to reopen if the issue persists. :)