I am following the "Learning LibGDX Game Development" book to make a simple game. I am in the menu creation section where we create a stage and render it with debug borders.

The book says to use Table.drawDebug(stage) but this static method seems to have been removed from the frameworks Table class entirely.

I am importing com.badlogic.gdx.scenes.scene2d.ui.Table; below is my code:

@Override
public void render(float deltaTime) {
    Gdx.gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    if (debugEnabled) {
        debugRebuildStage -= deltaTime;
        if (debugRebuildStage <= 0) {
            debugRebuildStage = DEBUG_REBUILD_INTERVAL;
            rebuildStage();
        }
    }
    stage.act(deltaTime);
    stage.draw();

    Table.drawDebug(stage);
}

The last line, Table.drawDebug(stage); has the compilation error "The method drawDebug(ShapeRenderer) in the type Table is not applicable for the arguments (Stage)"

Is there a new way to draw the stage in debug mode?

This has changed once again.

The correct code for the method is currently as follows, as stage.setDebug() has seemingly been removed (can't find what version that happened) and replaced with stage.setDebugAll(true);:

@Override
public void render(float deltaTime) {
    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    if (debugEnabled) {
        debugRebuildStage -= deltaTime;
        if (debugRebuildStage <= 0) {
            debugRebuildStage = DEBUG_REBUILD_INTERVAL;
            rebuildStage();
        }
    }
    stage.act(deltaTime);
    stage.draw();
    stage.setDebugAll(true);
}

Scene2d API documentation for the Stage class.

Found the answer, instead of the static Table.drawDebug(stage); call there is an instance method called stage.setDebug().

  • 1
    With the current version of libGDX, this appears to no longer be the case, at least if this is swapped out in the same place as where that book puts it. – James Skemp Mar 5 '15 at 18:22

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.