Stopping Touch Propogation...been trying for hours now. Solved while asking. :P
***Fixed***
***Thanks**
***Posting anyway in case it helps anyone :)
:) Yes I'm a noob, and yes the answer will be simple.
I have a board game which has a human and cpu player that take turns.
When the CPU player is taking its turn, I want to disable all touch events except the main menu button.
I have created a screen sized imageRect, added it to the localGroup right at the end so its supposedly on top, set its alpha to .5 so I know if its there or not ;) and have a couple of functions that run at the end of each turn to add and remove event listeners as follows...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | function blockTouch() battle.overlay:addEventListener( "touch", battle.overlay ) battle.overlay.alpha = (.8) td(100,function() lg:insert(battle.overlay) end) end function unBlockTouch() battle.overlay:removeEventListener( "touch", battle.overlay ) battle.overlay.alpha = (0) end and overlay = display.newRect(0,0,display.contentWidth,display.contentHeight) overlay:setFillColor(0,0,0,100) function overlay:touch(event) --print("Touched Overlay") return true end |
This works for one of the buttons on the screen, but all the others still register touch events...
******************************************************************
OK, I just figured it out while typing this. Strange how writing things down make them easier to process :)
I was using two different listeners for different parts of my code.
touch and tap
The buttons that were still working were listening for taps.
Sigh.