Sign in to follow this  
The Communist Duck

Signal pattern and game events

Recommended Posts

Hi. I've been looking around for a decent way of handling events in my game. I originally had a big enum with events and then a lot of if(){ } else if {} statements. It wasn't the best system, IMHO. After generally looking around the internet/these forums, the signal pattern seems to be recommended a lot. I've looked at boost.signals and it looks good, but I was just wondering roughly how this would be implemented. I've given it thought but I cannot think of anything except a few vague ideas, even after repeatedly reading the examples in the boost docs. Only thing I've managed to think of is each subsystem has-an eventListener that registers to only the events it wants (pretty normal). Then something to do with each event sent to the eventManager would be connected to the signal. These then get sent to the listeners that are interested, and the slots disconnected. I'm sorry if it seems I'm just asking for people to do it for me, because I don't want that. Thanks guys, if you get me. :)

Share this post


Link to post
Share on other sites
Lookup "signal slot pattern" or "signal slot mechanism". I think this is what you are describing. In C++ this is normally implmented using delegates which are usually just function pointers. Each slot is like a container of listeners which are just pointers to functions that handle an event. The event is the signal.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this