Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LibGDX scaling 2d graphics

I have problem with stretching sprites in LibGDX.

I have one png file for the sky in the game (1x1000 px) and i want to do it 1000x1000px

sprite.setSize(pixelWidth,pixelHeight);

Edit: Here is the image that I want to stretch - sky . It has little gradient from the top to the bottom as you can see. I want to make it 1000px in width. I expect image that has color-change in the width.

But I get this strange result: ImageImage

You can see that there is something like gradient in width, even with lines, but with no reason, because I am scaling 1px image...

The strange thing is that everything looks fine on other PC's and mobile phones... But I don't think that the problem is in my PC!?

I don't know what to try... Any ideas?

Sorry if I didn't explained it very well.. and sorry for my bad english

Final: It was from the filtering. I changed the filter from linear to nearest and everything was fine

like image 269
Yasen Bagalev Avatar asked Nov 01 '22 13:11

Yasen Bagalev


1 Answers

i dont understand what your question realy is but a good way to scale a sprite is like this

sprite.setSize(scrw * 0.16f, scrw * 0.16f);

here scrw is your viewport's width

like image 61
sandeep kundliya Avatar answered Nov 04 '22 06:11

sandeep kundliya