Search code examples
libgdx

why windows are duplicated on my screen when I set position of window at runtime ? (LIBGDX)


Problem: Windows are cloned on screen, when set the position of the window.

In my ApplicationAdapter.create() I create a Window and add it to the stage:

window = new Window("titleWindow", skin);
stage.addActor(window);

in the ApplicationAdapter.render() I reposition the window as follow:

    if(rendercount % 100 == 0){
        window.setPosition(100 + count,300);
    }
rendercount++

Why my window is cloned on my screen ? I just wanted to move it.

enter image description here


Solution

  • Are you clearing your screen in the beginnig of the render() method?

    Gdx.gl.glClearColor(0, 0, 0.5f, 0.6f);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);