Hello everyone..
There has been a problem with corona that when you place one view over the other and when you touch the object in front of the other, touch will be migrated to the object below it. To prevent this there is a mechanism in corona.
Here is how we solve this in corona.

display.getCurrentStage():setFocus( your_touched_obj)

here is a sample code.


local img1 = display.newImage("android_1.png")
local img2 = display.newImage("android_2.png")

function touchedImageOne()
	print ("touched Image One")
end

function touchedImageTwo()
	print ("touched Image two")
end

display.getCurrentStage():setFocus( img2 )
img1:addEventListener("tap",touchedImageOne);
img2:addEventListener("tap",touchedImageTwo);

Check the console for the output
Here is a source code example for this project.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

 

 

 

Theme by HermesThemes

Copyright © 2018 CoderzHeaven. All Rights Reserved

Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.