Skip to content Skip to sidebar Skip to footer

Libgdx Distorted Texture When Using Camera.settoortho(false, Game_width, Game_height);

I'am trying to make libgdx game, adn i've got 2 problems now: 1. When im using camera.setToOrtho(false, GAME_WIDTH, GAME_HEIGHT); my textrure of player is distored, one eye is big

Solution 1:

It is distorted because you are using a fixed width and height for the camera, so it simply stretches to fit whatever size window/screen you're putting it on.

Incidentally, StretchViewport does the same thing (distorts the scene to fit the dimensions you gave it to the window). But you just created a viewport without actually calling update() on it, so it's not doing anything.

You most likely want to use ExtendViewport or FillViewport to avoid stretching, but other options are available. Read about them here.

Your viewport won't properly respond to screen rotations (or desktop window resize) unless you put viewport.update(width,height) into the resize method. And you have to call update on it at least once regardless, using the actual screen dimensions. This is most convenient by simply putting viewport.update(width,height) into the resize method.

Post a Comment for "Libgdx Distorted Texture When Using Camera.settoortho(false, Game_width, Game_height);"