Tags

, , ,

To create the game , i thought that i should start from developing some common usage tools.

At today , i started developing an event dispatcher with two simple functions:

  • addListener
  • fire event

The purpose is simple: i define events with a name, and to that event i attach listeners.
When the event is fired, all listeners attached to that particular event are executed.

So an example of use could be:

event_dispatcher.addListener(‘my_event_name’,t.fire_function)

and somewhere else

event_dispatcher.dispatch(‘my_event_name’,param1=value1,param2=value2)

 

It’s simple ,but it works at the moment.
I’m not planning of developing an event-driven system, but if i’d need something similar, well, now i have it.

Advertisements