czyzby/gdx-lml

gdx-lml multiple (Sub)View classes for a single view

implicit-invocation opened this issue · 2 comments

I have a <80 LoC lml file and a >400 LoC java class to inject the actor, update the actor (according to the game data) and handle actions.
I know that I can use custom ActionContainer to handle actions.
But is there a way to use multiple java classes to handle a single view (inject Actor to multiple classes, run render in all those classes to update injected actors)?

Yes. You can use @LmlInject annotation on any field of your view, which will be created and populated by the LML parser. You can store groups of widgets in such injected containers to limit the amount of fields in your view class. As any Java class, it can also contain any extra methods that you want.

You can register as many action containers as you want, so you can split some of the logic into multiple classes this way.

Finally, you've got the power of plain Java - you can keep the actor fields and action handles in your view, but extract the logic into separate classes using plain Java and simple refactoring, without introducing any LML features.

@implicit-invocation If that solves your problem, feel free to close the issue. :)