This is a feature request, not a bug, and would be a good addition to the feature request forum.
At the moment you can implement hit testing by combining several objects, or in your object’s touch listener. The touch listener can explicitly filter the touch events it receives and only respond to some of them depending on their coordinates.
llocal shape = display.newCircle(display.contentCenterX, display.contentCenterY - 100, 100)
shape:setFillColor(200, 100, 50)
shape.name = "circle"
local square = display.newRect(display.contentCenterX, display.contentCenterY - 100, 80, 80)
square:setFillColor(0, 100, 200)
square.name = "square"
local square2 = display.newRect(square.contentBounds.xMin, square.contentBounds.yMin, square.width/2, square.width/2)
square2:setFillColor(200, 100, 50)
square2.name = "mask"
local function listener(event)
-- behave as if there is a hole in part of the square
print (event.target.name)
if event.target.name == "square" and event.x \> square2.contentBounds.xMin and event.x \< square2.contentBounds.xMax
and event.y \> square2.contentBounds.yMin and event.y \< square2.contentBounds.yMax
then
return false
else
print(event.name.. "hit at (" .. event.x .. ", " ..event.y.. ")")
event.target:setFillColor(255,255,255)
return true
end
end
square:addEventListener( "touch", listener )
shape:addEventListener( "touch", listener )
[import]uid: 6787 topic_id: 7203 reply_id: 34301[/import]