hit test using mask not rectangle

I suspect this is either something very basic or unsupported. I want to be able to “tap” a sprite or image and detect the hit based on the visible pixels not the bounding rectangle. Can someone point me in the right direction?

I have searched the forums and the docs in vain for a simple answer.

Thanks. [import]uid: 40000 topic_id: 7203 reply_id: 307203[/import]

i put a bug report in here
http://developer.anscamobile.com/forum/2011/02/15/windows-touchable-shape-not-being-set-physics-body

add your +1 for a fix [import]uid: 6645 topic_id: 7203 reply_id: 25350[/import]

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]