Search code examples
methodslibgdxdispose

LibGDX - method isn't called


public abstract class Level implements Disposable {
    Game game;
    Stage stage;

    ...

    stage.addAction(sequence(delay(10), new Action() {
        @Override
        public boolean act(float delta) {
            dispose();
            System.out.println("here");
            game.setScreen(new MainMenu(game));
            return false;
        }
    }));

    ...

    @Override
    public void dispose() {
        System.out.println("dispose called");
    }

    ...

}

In this piece of code, I want to call the Overridden dispose method. It says here in the command line as expected. However, it doesn't say dispose called. I am confused, how am I supposed to call dispose in this situation?

Or is there any easier way to do what I am trying to do here?


Solution

  • Okay I found it. Since it was an abstract class, I have extended new class to Level. It has its own dispose method and I haven't called super.dispose() so it was just calling an empty method.