How does one do Inter-Object communications (e.g. triggering events) in Corona? Some sample code would be great.
Notes:
-
I see there is a way to create custom events on an object, however it seems you really need a handle to that object before you can trigger (dispatch) it.
-
What I’m interested here is two completely separate objects. Eg say you clicked on a display object on the screen the ability to say in a global event type sense “MyInventoryHasIncreased”, and then have any other display objects that need to subscribe to this pick it up and adjust their display accordingly.
Subscribe
If you ever need global events, think about using the Runtime:addEventListener().
You can split the Runtime:addEventListener from the Runtime:dispatchEvent to get your desired object to object communication.