Hi,
I’ve read about events in several blog posts and I have a scenario and a question:
To decouple my game component, I want to register them for various custom events and when I need to trigger them, throw those events.
What I understood Corona suggests is table listeners, in other words, meaning that you throw an event on a table/object or any amount that you want.
It doesn’t suit my need because A) I have to remember that which objects needs this event and B) I don’t want to store reference of those table listeners in every scenario that I want to throw event.
So I thought of Runtime events and leads to my question:
Is there any way that I can register my tables/objects to Runtime events, such as we normally do with “touch” event and whatnot, and then when my game needs, I throw those events at Runtime and each of the objects that registered themselves for Runtime, grab the event and handle it?
Example use case:
When one of objects gets hit by a bullet, I throw a “MonsterGotHitWithABullet” and as I previously registered my UI, SFXmanager, FoodSpawner, etc to this event, they all receive this event and each respond accordingly.
Thanks.