Last Updated: February 25, 2016
·
19.8K
· drabiter

Scale your sprites properly in LibGDX

Also use this tip to greet "Hello All!" :)

For first tip, some lines of pseudo code to scale your sprite which instance of Image class while maintaining the aspect ratio.

//you have an instance of Image
Image image = createInstanceOfImage();

//These lines will resize your sprite to half of screen's width while keeping the ratio
image.width = .5f * Gdx.graphics.getWidth();
image.setScaling(Scaling.fillX);

//To resize in height's scale
image.width = .5f * Gdx.graphics.getHeight();
image.setScaling(Scaling.fillY);

If you can't figure out yet whether use width or height as scale, use Scaling.fill will help.