I have a weird camera problem that I can't solve! I add my actors to the main stage and use its camera too. Actors are constrained within the screen viewport.

I also have a second camera that I use for the parallax background. I check for touchDragged and touchDown to move the actor to that position. So I do:

public boolean touchDown(int screenX, int screenY, int pointer, int button) {
    getStage().getCamera().unproject(touchPosition.set(screenX, screenY, 0f));

    return false;

I can pan the parallax camera, and I do:

public void panBy(float x, float y)
    panTo.set((float)MathHelper.round(position.x + x, 0), (float)MathHelper.round(position.y + y, 0), 0);
    panning = true;

public void update() {
    if (panning) {
        position.x += (panTo.x - position.x) * panLerp;
        position.y += (panTo.y - position.y) * panLerp;

        Vector3 pos = new Vector3((float)MathHelper.round(position.x, 0), (float)MathHelper.round(position.y, 0), 0);

        if (pos.epsilonEquals(panTo)) {
            panning = false;


The drawing is done:

public void draw(Batch batch)
    //Start batch

    background.draw(batch, 1f);

    //End batch

Actors are handled by the stage right after the above draw call.

The above work fine individually. However when I pan and drag the actor the parallaxCamera follows the actor too. I the parallaxCamera to be totally independent and just keep scrolling.

Why do I have this behavior?


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.