In my application I have some classes that I would like to dispatch events from that are not display objects. They are basically some lua files that return a table. I would like to keep values and logic there and then dispatch an event from time too time.
The use case would be something like a display object that keeps state or data in another file and then listens for "change" events.
In Flash a class can extend EventDispatcher. I am wondering if there is a way to do something similar? My solution has been to just return "group" object instead of a plain old table.
Not sure, never tried that, but I assume not. When I need something like that I always either return group, or return a table that has a group as one of the properties.
another way to look at it is to think of it as observer/listener/broadcaster
in your main enterframe loop
you can have objects that listen for certain broadcasts
you can have objects that observe -
and objects that broadcast certain information
objects that are listeners register with broadcasters
objects that broadcasts register with the enter frame
and objects that observe register with other objects
http://userpages.umbc.edu/~tarr/dp/lectures/Observer.pdf
hope this helps.
c
That makes sense Carlos. I think what I would like to do is more like the MVP pattern in Flash, so I can have a View, Presenter and Data Model. Anytime the DM updates a value I would fire an "event" that the Presenter or view is listening for and then do logic to update view.
Make sense ? This type of flow works really well for "event" driven languages and SDKs.
That makes sense Carlos. I think what I would like to do is more like the MVP pattern in Flash, so I can have a View, Presenter and Data Model. Anytime the DM updates a value I would fire an "event" that the Presenter or view is listening for and then do logic to update view.
Make sense ? This type of flow works really well for "event" driven languages and SDKs.
usually the list of non-display objects you can at the end of each "transaction" you can then dispatch event to the objects have have registerd.
http://developer.anscamobile.com/reference/index/objectdispatchevent
one thing you can do if you want to, if you don't want to manage the observer/listener/broadcast overhead is to use a display object (like an image) that is truly transparent and one pixel h*w
c