android - How to disable hidden buttons in Corona? -
let's say
-i have button listens "tap" event, , directs function something.
-i put imageract covers button. 1 layer up.
when click on cover image above area buttons lies behind , event function still executes.
how avoid this?
example:
local function hidebg() display.remove(logo3) logo3=nil end local logo2= display.newimage("logo.png") logo2.x=display.contentcenterx logo2.y=280 logo2.width=200 logo2.height=74 logo2:addeventlistener("tap", hidebg) local cover =display.newimagerect("new game a.png", 480,320) cover.x=display.contentcenterx/2 cover.y=display.contentcentery/2
the hidebg() function still executed although "logo2" covered "cover" image.
i know make button isvisible=false , solve problem, have dozens of buttons in different groups in different layers, , wonder how in smart way. maybe somehow disable whole group? don't know.
there 2 ways can disable button in project.
1) create listener cover
below , return true
follows:
function coverpressed() return true; end cover:addeventlistener("tap",coverpressed)
2) check if cover
exists, , remove listener of logo2
as:
logo2:removeeventlistener("tap", hidebg)
keep coding............ 😃
Comments
Post a Comment