In short answer,
InputAdapter so you could subclass
Stage and override all of the
InputAdapter methods. If you did this, you would have to implement your own algorithm to determine which Actor was touched.
Personally, I think that using the event propagation and hit detection that
Stage already has is worth putting the listeners on the Groups/Actors. However, this doesn't mean that you have to handle all events in the
If you want all input handling to be done in a central location, I suggest using the command pattern. This way, you can inject commands into your
Actors that they will call when they receive input and the commands will forward any relevant data to your central input handler.
Answer After Clarification
As far as memory overhead, your memory footprint won't be drastically different by attaching listeners to your
Actors. Regardless of whether you use attach any listeners, each
Actor creates a
DelayedRemovalArray to hold all of the listeners. Each of your listeners will take differing amounts of memory, depending on how much your data listener implementation stores, but this amount will probably never be large.
Listeners attached to
Actors are not pooled and, unless you use a resource needing disposal in your handler, do not need to be disposed. The garbage collector will take care of all listener handles when there are no more references to them.
The only processing bottleneck I can see with listeners would be if you are constantly creating them and destroying them. You could potentially pool listeners, but then you would have to free them once the
Actor using them is no longer in use. In this scenario, I suggest pooling the
Actor instead as similar
Actors are going to need similar listeners.
Trying to optimize listener memory is probably an over-design to begin with and I would wait until they have become a proven problem before doing anything about them. Having
Actors hold their own listeners will make your game more modular and will prevent a monolithic event handler which will be hard to maintain.
The benefits of keeping the code modular and using the
Stage's event propagation system outweigh any potential memory optimization by having a single monolithic listener. I suggest putting them on the