11
\$\begingroup\$

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?

\$\endgroup\$
0

2 Answers 2

12
\$\begingroup\$

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.

\$\endgroup\$
5
\$\begingroup\$

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

\$\endgroup\$
1
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ Mar 5, 2015 at 18:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .