how to handle actions

hello,

in my game i have a lot of assets that should trigger certain actions when they are clicked, doubleclicked, stepped on, etc…

now the problem is that one and the same asset could trigger very different actions.

for example clicking a button may send a message to the server, while another instance of the same button class may also make the avatar jump around.

what is the best way to organize these different kinds of actions in terms of software - architecture. are actionlisteners an option?

thanks!

Seems to me you’re describing the same things Sun developers had to think about when they designed the AWT/Swing event model ;D

And while I have some issues with the event model, it certainly does have its merits.

I usually register an ActionListener on each button, and then call the real'' method (which is probably located in some very different class) from the actionPerformed method as just about the only thing. Thus the role of the ActionListener is minimized, which is nice because you probably want more than one way to call the real’’ method (hotkey, menu selection or whatever).

thank you, i ended up with my own AssetListener :wink: