I am attempting to have animated dialog text for my libGDX game. I found a useful resource on github called Typing Label and i am having some troubled getting it working. Could someone help me with this. Also in the examples it says stage.add and i dont have a stage object declared. what type of object should that be.

 TypingLabel label = new TypingLabel("Hello world!", skin);

To use any type of Actor (TypingLabel is an Actor) you need a Stage object like the examples say. You also need to draw and update this stage object every game tick so that the Actors can animate and render properly.

// Instance variable
private Stage stage;

public void create() {
    stage = new Stage(); // Note: There are multiple constructors available
    stage.add(new TypingLabel("Hello world!", skin));

    Gdx.input.setInputProcessor(stage); // Only needed if you have input such as buttons

public void render(float delta) {
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); // Clear screen so we don't get artifacts.  

    stage.act(); // Update all actors
    stage.draw(); // Draw all actors

The official libgdx wiki has more information about how to use Stage, Actors, and other parts of Scene2D.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy