In this libgdx tutorial, the author says he's not happy with the circular dependency between the game and the screens.

How can this diagram:

enter image description here

be improved to remove that dependency?


1 Answer 1


You can't. Game class is the one that handles the Screens, and the Screens need to be able to communicate with it to tell it which Screen it should set next.

That dependency isn't really a big of a deal. Just having a reference to the Game in your Screens (via the abstract Screen that all of them extends from).

If you want to change that, you would need to create your own Game and Screen classes, with a different design. (Not worth the effort if you ask me)

  • \$\begingroup\$ OK, so there's no real problems using this model for developing a proper game? \$\endgroup\$
    – mal
    Dec 13, 2013 at 7:27
  • \$\begingroup\$ Nop. Just have the Game reference and use it to go from Screen to Screen. (game.setScreen(new SettingsScreen) for example) Nothing wrong with it. \$\endgroup\$
    – Daahrien
    Dec 13, 2013 at 18:17

You must log in to answer this question.

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