I have started learning LibGDX and I have been making a few little games to learn how it all works but ever since I started using stages and actors, all of my textures stretch horizontally and I can't seem to fix it at

public class GameScreen extends BaseScreen
private BaseActor background;
private PhysicsActor spaceship;
private BaseActor rocketfire;

private PhysicsActor baseLaser;
private AnimatedActor baseExplosion;

private ArrayList<PhysicsActor> laserList;
private ArrayList<PhysicsActor> rockList;
private ArrayList<BaseActor> removeList;

public GameScreen(BaseGame g)

public void create()
    spaceship = new PhysicsActor();
    Texture shipTex = new Texture("fire.png");
    shipTex.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    spaceship.storeAnimation("default", shipTex);
    spaceship.setPosition(400, 300);

public void update(float dt)


BaseScreen class

public abstract class BaseScreen implements Screen, InputProcessor
protected BaseGame game;
protected Stage mainStage;
protected Stage uiStage;
public final int viewWidth;
public final int viewHeight;
private boolean paused;

public BaseScreen(BaseGame g)
    this(g, 1024, 600);

public BaseScreen(BaseGame g, int viewWidth, int viewHeight)
    game = g;
    this.viewWidth = viewWidth;
    this.viewHeight = viewHeight;
    mainStage = new Stage(new FitViewport(viewHeight, viewHeight));
    uiStage = new Stage(new FitViewport(viewWidth, viewHeight));
    paused = false;
    InputMultiplexer im = new InputMultiplexer(this, uiStage, mainStage);

public abstract void create();
public abstract void update(float dt);

public void render(float dt)
    if (!isPaused())

    Gdx.gl.glClearColor(0, 0, 0, 1);

I changed the texture to a perfect red square but when renderered on the screen it was more rectangle shaped than square (horizontally) and I have no idea why. I read somewhere that it was something to do with the camera but I have no idea what to do to fix it! Please help :O

  • \$\begingroup\$ If one of the answers below fixed the issue, you might want to upvote/mark it as accepted :) \$\endgroup\$ – Vaillancourt Aug 31 '19 at 12:19

There is a mistake in your Viewport parameters that you use in the mainStage. Instead of passing the viewWidth argument, you passed the viewHeight, ending up with a FitViewport(viewHeight, viewHeight).

Change it to FitViewport(viewWidth, viewHeight) and you should be good to go.


try overriding the "resize" method of your "basecreen" class and update the viewport there

public void resize(int width, int height) {
    stage.getViewport().update(width, height);

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.