How to move Stage?
I am looking for an example:
stage.draw(x,y); // ???
Thanks you
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It only takes a minute to sign up.
Sign up to join this communityYou 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()
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!