I am using libgdx to make a running game. I am using vertical parallax background. I have successfully implemented parallax background many times. But for this game, I want my Texture region to fit my screen size. I tried several things but the texture region is streched badly.Here is a screenshot.

enter image description here

I used this code:

texture_bg  = loadTexture("data/road1.png");
bg  = new TextureRegion(texture_bg, 0,0, 600, 600);

that is obvious. Now ..what should I do... so that while making it as a parallax background... it would fit my screen... I am worried only about the width.... as if the width will fit the screen width... it will look like a running road... no matter how long the height is.

I found some solution here https://stackoverflow.com/questions/7551669/libgdx-spritebatch-render-to-texture

but not able to understand.. it seems somewhat complex. Please make it clear if it is the solution or suggest on other possibilties.

  • \$\begingroup\$ Do you just want the texture to repeat over the screen? Like this? github.com/mattdesl/lwjgl-basics/wiki/images/lflHc.png \$\endgroup\$ – Vaughan Hilts Apr 8 '14 at 18:21
  • \$\begingroup\$ I just want the texture to resize itself properly. Is it posible to create a texture with a particular size that will scale properly to an image n libgdx. \$\endgroup\$ – Vishal Kumar Apr 16 '14 at 18:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.