It looks like you're new here. If you want to get involved, click one of these buttons!
function ArmasMontagem:HabilitaBotoes() --Listener do botão 1 (Spout) wpPiece1:addEventListener("click", function() numBox = 1 self.onClickButton() end ) --Listener do botão 2 (HoseAndButton) wpPiece2:addEventListener("click", function() numBox = 2 self.onClickButton() end ) --Listener do botão 5 (Globe) wpPiece5:addEventListener("click", function() numBox = 5 self.onClickButton() end ) --Listener do botão 4 (WaterPump) wpPiece4:addEventListener("click", function() numBox = 4 self.onClickButton() end ) --Listener do botão 3 (Trigger) wpPiece3:addEventListener("click", function() numBox = 3 self.onClickButton() end ) end function ArmasMontagem:DesabilitaBotoes() wpPiece1:removeEventListener("click", function() numBox = 1 self.onClickButton() end ) wpPiece2:removeEventListener("click", function() numBox = 2 self.onClickButton() end ) wpPiece5:removeEventListener("click", function() numBox = 5 self.onClickButton() end ) wpPiece4:removeEventListener("click", function() numBox = 4 self.onClickButton() end ) wpPiece3:removeEventListener("click", function() numBox = 3 self.onClickButton() end ) end |
Comments
You should use something likes Game State to control Game Loop.
In this case, we only addEventListener and no need to removeEventListener. Logic of clickable or not clickable can be check on onClickButton base on Game State and numBox (click count)
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps