Hi, I’m searching to solve my problem about closing the sidebar menu with touch on dark background outside of sidebar menu…
Sidebar container has negative width, by transition.to I show it
At the moment sidebar menu is closed when touch is done on sidebar menu container or background with low opacity… To close sidebar I only need a touch on dark background…
This is the code
[lua]local sidebarGroup = display.newGroup( )
functions.setRef(sidebarGroup, “topLeft”)
sidebarGroup.x= 0
sidebarGroup.y= 70
local backOpacity = display.newRect( 0 , 0, W_screen , H_screen )
backOpacity:setFillColor( 0, 0, 0, 0.4 )
functions.setRef(backOpacity, “topLeft”)
backOpacity.isVisible = false
local sidebarContainer = display.newRect( 0 , 0, 0 - W_screen / 1.5, H_screen )
sidebarContainer:setFillColor( 0, 139 / 255, 190 / 255 )
functions.setRef(sidebarContainer, “topLeft”)
sidebarGroup:insert( 1, backOpacity )
sidebarGroup:insert( 2, sidebarContainer )
local function sidebarShowHide( event )
if(event.phase == “ended”) then
print( “sidebarShowHide” )
if(sidebarContainer.x <= 0 ) then
transition.to( sidebarContainer, { time=400, x=(W_screen / 1.5) } )
backOpacity.isVisible = true
else
transition.to( sidebarContainer, { time=400, x=0 } )
backOpacity.isVisible = false
end
end
return true
end
local function sidebarHideBodyClick ( event )
if(event.phase == “ended”) then
print( “sidebarHideBodyClick” )
if(sidebarContainer.x > 0 ) then
transition.to( sidebarContainer, { time=400, x=0 } )
backOpacity.isVisible = false
end
end
return true
end
menubutton:addEventListener( “touch”, sidebarShowHide )
backOpacity:addEventListener( “touch”, sidebarHideBodyClick )[/lua]
Any solutions?
Thanks