I think Joakims problem is that the background group reacts to touches, even when the smaller foreground group was touched.
To prevent that, you have to stop the event bubbling up by returning true.
sample:
local group1 = display.newGroup()
local group2 = display.newGroup()
myObject1 = display.newRect( 10, 10, 200, 200 )
myObject1:setFillColor ( 100, 100, 100 )
myObject2 = display.newRect( 100, 100, 100, 100 )
group1:insert(myObject1)
group2:insert(myObject2)
function doOne(event)
local t = event.target
if ( event.phase == "ended" ) then
print ("Group 1")
end
end
function doTwo(event)
local t = event.target
if ( event.phase == "ended" ) then
print ("Group 2")
end
return true -- if !true, bubbling up occurs
end
group1:addEventListener("touch", doOne)
group2:addEventListener("touch", doTwo)
-finefin [import]uid: 70635 topic_id: 22426 reply_id: 89477[/import]