Search code examples
libgdxstagescene2d

Libgdx : sliding an actor out of stage bounds with Action MoveTo()


I am using a Scene2D action to add a slide moving effect to an actor in my stage.

Window w = new Window(mytitle, myskin);
w.setPosition(stage.getWidth()/2 - w.getWidth()/2, 0);
w.addAction(moveTo(stage.getWidth()+w.getWidth(), 0, 1));
stage.addActor(w);

My goal is to move this window from the x-center of the stage to the right bound of the stage PLUS the window's width.

So far this code only makes the window move from the x-center of the stage to the right bound of the stage MINUS the window's width.

To explain it graphically: enter image description here

So how can I use a MoveTo Action to move an actor BEYOND the bounds of the stage?

I guess I could artificially create a stage bigger than what I display on screen but that sounds like solving a problem with additional problems.

Thanks for your time


Solution

  • This worked for me: window.setKeepWithinStage(false);

    Here is the full post: libgdx position window outside of stage