Jump to content
  • Advertisement
Sign in to follow this  
The Communist Duck

Signal pattern and game events

This topic is 3013 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!