Search code examples
cameralibgdxstage

Absolute position of a stage in libgdx


I have a camera and a stage in my project. When I move up the camera, the stage follow it but I want the stage stay at the same place.

I would set the camera to the stage : this.stage.setCamera(camera);

This worked before the update of libgdx 0.9.8 -> 1.0.1 but this function doesn't exist anymore.

How can I do this ?

Thanks.


Solution

  • They added the Viewport stuff. See this artikle for more information. The stage itself does not have any camera anymore. But the viewport of the stage has one.

    This should solve your issue if you already use a viewport.

    stage.getViewport().setCamera(cam);