3
\$\begingroup\$

How to move Stage?

I am looking for an example:

stage.draw(x,y); // ???

Thanks you

\$\endgroup\$

2 Answers 2

5
\$\begingroup\$

You should not move the stage, you should move the viewport for the stage.

You need to make sure when you call this

stage.getViewport().update(width, height, false);

that the last parameter is false, so that the viewport is not always centered. You can then set

stage.getViewport().getCamera().position.x

or call

stage.getViewport().getCamera().translate()

before calling

stage.getViewport().getCamera().update()
\$\endgroup\$
1
\$\begingroup\$

if you really want to move all sprites on Stage, use root

My example (I use stages as windows and make transitions for window changes)

 private void startShowTransition(Stage stage) {
    stage.getRoot().setX(WINDOW_START_X);
    stage.getRoot().setY(WINDOW_START_Y);

    stage.addAction(Actions.moveTo(WINDOW_FINAL_X,
            WINDOW_FINAL_Y,
            WINDOW_TRANSITION_DURATION));
}

And note - you can use Actions for smooth stage changes effects!

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .