So i have a created a background which is 1920 x 1080 in size.
And i have a window that is 1280 x 720 (will not always be this size)
Now when i render the sprite using this code:
public void render(float delta)
Gdx.gl20.glClearColor(0.2F, 0.5F, 1F, 1F);
sb.draw(Assets.splash_spr_bg, 0, 0);
The sprite appears in the window but not the whole sprite, just like 1/2 of it.
Now here's my question:
·How can i make the sprite fill the whole screen no matter what size the screen is?
Thanks for any help! :)
Best How To :
I recommend using Viewports for this: https://github.com/libgdx/libgdx/wiki/Viewports
Its a great way to handel screen sizes. To make it fill the whole screen u probably have to try something like:
Picture1.setX(stage.getWidth() / 2 - Picture1.getWidth() / 2);
Picture1.setY(stage.gethight() - Picture1.getHeight() /)
In this example i use a stage, but it will work without just remember that u get the screen width and height instead or set them to 0,0 and place it under in the corner. Also notice that i cut the width in half, this is because it will otherwise always render outside your screen. Then u could try and use something like:
Picture1.setSize(stage.getWidth() / 2, stage.getHeight()):
the other way u could do it is by setting your viewport zoomed in on the picture (so the same size) that way it will also give you a full screen view even tho i dislike that idea, but thats a personal preference. Also this later one wont make your background look all stretched and pixelated because it isn't being resized, but if u take a picture thats big enough you also wont notice it in the first option.
Just mess around a little with it, its pretty easy.
Example of how to implement Viewport: http://pastebin.com/3SrWKcEg