Hi Guys,
Thank you for the prompt responses. I apologize for not posting my code (I’m aware that can be frustrating when you are offering your time to help). My code is very complex with many scripts that handle display groups involved with these touch events (likely too complex and the true source of my problem). I suspect my issue is either 1) associated with the order of one of my display groups changing incorrectly, or 2) associated with something I’m doing incorrectly in my touch listener function. First, I did verify just now that the issue is not the sdk version as the following simple test code runs correctly when touching in the overlapping and non-overlapping regions (when both retaining and commenting out “return true” in the touch listener functions):
local gs = {} -- table for groups local all\_func = {} -- table for functions all\_func.testtouchfun = {} all\_func.testtouchfun2 = {} gs.touchsensetest = display.newGroup( ) gs.touchsensetest2 = display.newGroup( ) ----------------------------------------- ----------------------------------------- gs.touchsensetest.detector = display.newRect( gs.touchsensetest, display.contentWidth/2, display.contentHeight\*.5, 300, 400 ); gs.touchsensetest2.detector = display.newRect( gs.touchsensetest2, display.contentWidth/3, display.contentHeight\*.4, 400, 400 ); gs.touchsensetest2.detector:setFillColor( 1,0,0 ) gs.touchsensetest2:toBack() ----------------------------------------- functions ----------------------------------------- function all\_func.testtouchfun( e ) print("called test touch0000000000000000000000000000") return true end function all\_func.testtouchfun2( e ) print("called test touch2------------------------------") return true end ----------------------------------------- listners ----------------------------------------- gs.touchsensetest.detector:addEventListener( "touch", all\_func.testtouchfun ) gs.touchsensetest2.detector:addEventListener( "touch", all\_func.testtouchfun2 )
So, not surprisingly, it is not associated with the sdk version (not sure why I experienced the issue after my update though). I do have a question about something I’m doing in my touch listener functions. Below is abridged code from my game:
-- -------------------------------------------- touch and drag-- -------------------------------------------- function all\_func.touchScreen( e ) print("called test touch0000000000000000000000000000") colony\_guicreate\_module.touchScreen(e.target, gs.main\_group, "more display groups an d variables" ) return true end -- -------------------------------------------- tap\_upgrade -- -------------------------------------------- function all\_func.tap\_upgrade( e ) print("called tap\_upgrade------------") if (some conditions) then -- some code colony\_B\_funs\_module.display\_upgrade(gs.main\_group, "more display groups and varia bles") return true else -- some code --return true end end -- -------------------------------------------- More code -- -------------------------------------------- -- Within "scene:create" gs.touchsense.detector:addEventListener( "touch", all\_func.touchScreen ) gs.upgrade\_group:addEventListener( "tap", all\_func.tap\_upgrade )
I create an EventListener for a hittable but alpha=0 rectangle display object (for example, gs.touchsense.detector - see 2nd to last line). The listener function for this (all_func.touchScreen) then calls a function (colony_guicreate_module.touchScreen (3rd line)) from a separate script. I “return true” after calling the script within the listener and also return true at the end of colony_guicreate_module.touchScreen in the script. Is this an issue? Will either “return true” terminate the touch propagation? Thank you for the help.