Slick Forums

Discuss the Slick 2D Library
It is currently Wed May 22, 2013 12:14 pm

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Fri Feb 11, 2011 6:10 pm 
Offline

Joined: Fri Feb 11, 2011 5:56 pm
Posts: 1
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group