libgdx position window outside of stage

北慕城南 提交于 2020-01-04 02:47:07

问题


I am wondering how to use MoveToAction (or any method) for positioning a scene2d Window outside of the stage. I want the menu to slide in and out.
My Stage and my Skin are stored in my world class.

These methods work fine for now, while not at all animating it:

Window window = new Window("NoteBook", world.skin);
    ...

public void closeBook() {
    window.remove();
}

public void openBook() {
    world.stage.addActor(window);
}

This is how I am trying to update these functions to allow animation. Here the windows are already added to the stage once during init, so these methods handle only the animation.

public void closeBook() {
    MoveToAction action = new MoveToAction();
    action.setPosition(-200, -200);         // somewhere off screen
    action.setDuration(0.5f);
    window.addAction(action);
}

public void openBook() {
    MoveToAction action = new MoveToAction();
    action.setPosition(0, 0);           // original location
    action.setDuration(0.5f);
    window.addAction(action);
}

This seems to partially work, in that it does animate the window's movement, but it stops at the edge of the screen and won't break past it. I've tried adjusting my stage's viewport dimensions but it still always stops at the edge.

So the question is, how do I position a scene2d Window outside (or seemingly outside) of the stage?


回答1:


Try this:

window.setKeepWithinStage(false);

Which should allow the window to move outside of the stage.



来源:https://stackoverflow.com/questions/20021238/libgdx-position-window-outside-of-stage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!