I made a button by the code below. The A02(shadow button/over file) sometimes remains visible after pressing the button, I think it is because another button is pressed at the almost same time, so the [event.phase == “ended”] which make the A02 be not visible ailed to function.
How can I solve it? thanks a lot!
CODES ARE AS BELOW:
local A0 = display.newRoundedRect(30,260,36,260,7)
A0:setFillColor( 1 )
local A02 = display.newRoundedRect(30,260,36,260,7)
A02:setFillColor(0.9275, 0.9275, 0.9275)
A02.isVisible=false
A0effect = function(event)
if event.phase == “began” then
A02.isVisible=true
audio.play(A0Sound)
end
if event.phase == “moved” then
A02.isVisible = false
end
if event.phase == “ended” then
A02.isVisible=false
end
end
A0:addEventListener(“touch”,A0effect)