Using the framework i found real need of custom user broadcast event like the enterFrame or mouseDown , etc. It would be really great to have such event to connect to all registered objects. Even further if we have user defined global timer with event broadcasted to registered objects. Example of use: graphics update goes in enterFrame event, complex logic could be driven with less frame rate like half or third of the graphics and we will need only one timer to run it instead of timer in every object or with LUA iterator outside the objects. Or am i miss something?
Comments
I use the following in my main.lua:
The original post for this was by @atilim in October here: http://www.giderosmobile.com/forum/discussion/comment/13991#Comment_13991
function broadcastEvent(event)
for k in pairs(allEventDispatchers) do
k:dispatchEvent(event)
end
end - needs to be done native. /btw pairs iterator is almost 8 times slower than i=1,#allEventDispatchers./
I am trying to stick to the original API and stay as much inside of "C" compiled code as possible. I know lot of people extend the API by writing many functions in LUA but some things just need speed. For example i really don't like particle system running on interpreter, main reason to remove the missile smoke tail in my project.
Likes: moopf
You could define something an EventDispatcher class and store it on the global level or pass it into your main game class etc and just add event listeners to that object. I saw someone do that in another thread here awhile ago.