Hello everyone!
I would like clarification on the EventDispatcher.
I have two classes:
-
Button
local M = {} function M.new() local button = display.newCircle( 160, 250, 20 ) button:setFillColor( 0, 1, 0 ) button.name = “button” function button:tap( event ) print(“You pressed the button”) --send an event to open the gate? end button:addEventListener( “tap” ) return button end return M
-
Gate
function M.new() local gate = display.newRect( 80, 100, 100, 20 ) gate:setFillColor( .1, 8, 1 ) gate.name = “Gate” gate.dir = “dx” local function openGate( event ) print(“Open the gate”) --my code to open gate… end return gate end return M
The fact is this, if I use normal EventDispatcher, I have to use Runtime events and I create many I’m afraid that all these controls overplay the game by slowing it down…
Looking for I found this: http://swfoo.com/2014/07/11/send-custom-events-with-eventdispatcher-for-corona-sdk/
In my opinion, It consume less than Runtime events, so I tried using it. But I can not tell the classes between them.
So I have two questions:
- How do I use the link module to communicate the two objects?
2.Create so many Runtime events consuming a lot? is it better to use the “normal” events then, or the module in the link?