My understanding from your initial post is that you want to drag both images, but the bottom image can also receive tap events through the top image. To do just that here is my code:
local a, b = display.newRect(0,0,500,500), display.newRect(100,100,200,200) b:setFillColor(0,255,0) a.name = "bottom" b.name = "top" local function touch(e) print("touch "..e.target.name.." "..e.phase) if (e.phase == "began") then e.target.hasFocus = true display.getCurrentStage():setFocus(e.target) e.target.prev = e return true elseif (e.target.hasFocus) then if (e.phase == "moved") then e.target.x, e.target.y = e.target.x+(e.x-e.target.prev.x), e.target.y+(e.y-e.target.prev.y) e.target.prev = e else e.target.hasFocus = false display.getCurrentStage():setFocus(nil) e.target.prev = nil end return true end return false end local function tap(e) print("tap "..e.target.name) return true end a:addEventListener("touch",touch) a:addEventListener("tap",tap) b:addEventListener("touch",touch)
Running the code above you’ll notice that any tap event is also preceded by two touch events (began and ended phases.) This is because a tap event is the accumulation of a start and end of a touch. (To be really good, the tap should allow a little movement - moved phases - between the began and ended phases, because human fingers just aren’t that precise.)
If you want to avoid the began and ended phases of touch events and only receive a single tap event, you’ll need to use only touch events (don’t listen for tap events) and do a lot of work to reduce the two phases down to a single tap. I have tried this before and produced a couple of libraries which might help you, posted to the code exchange - please be aware that this is pretty old code now, but it certainly worked well in 2011:
http://developer.coronalabs.com/code/sanitised-touch-library
You can find my other libraries, samples and tutorials here:
http://springboardpillow.blogspot.co.uk/2012/04/sample-code.html
Hope this helps.