|
Hi all!
I recently started using Slick2D with the Spartan Framework to build myself a small game and was wondering: where the hell do I put responsibility for registering the correct listeners and adding the forms to the rendering manager and such.
Here is a simple situation: You have an inventory button to open the inventory menu. As you might have surmised; at the very least, it includes a form and a listener.
I could go the very specialized way and have the listener be for all the buttons and check which got hit and then take care of everything needed to show the inventory screen. That does not sound like very entity-oriented now, does it?
So far I have:
InventoryButtonForm(Image)
ToggleAction(Manager, ActionID)
MouseClickListener(Form, Action)
The MouseClickListener checks for clicks inside the form boundaries and register the action with the ActionManager when it hits.
The ToggleAction calls the Manager with the ActionID when it gets run by the ActionManager. (In that case, manager = GUIManager and ActionID = TOGGLE_INVENTORY_SCREEN)
The manager then proceeds to... well do everything; initialize inventory, registers the inventory screen listeners and add the inventory Form to the rendering manager (or remove both if closing).
The manager feels kind of awkward, is there a better way to do this?
_________________ Meh.
|