Runtime touch event and object's touch event problem!!

Hello everyone,
I have a runtime touch event called OnScreenTouch ( to do stuff like swipe the screen left and right), and an object1 with its listener created like this
local function OnObjectTouch(event)
// do stuff
print(“OnObjectTouch is called”)
end

object1:addEventListener(“touch”,OnObjectTouch)

The problem is after touching the object, although i did’t touch that object, i mean i touched out side of it, which is the screen , it always calls the OnObjectTouch listener. I tested it by printing it out as above. How to fix this, when i touch out side of that object i want to swipe the screen, not to do stuff that the onObjectTouch commands. Any suggestion? [import]uid: 33695 topic_id: 17009 reply_id: 317009[/import]

You didn’t touch the object but the event fired, is that what you’re saying?

If so - how large is the transparent area surrounding the image? [import]uid: 52491 topic_id: 17009 reply_id: 63980[/import]

Like peach says perhaps the transparent area around the image is too large. And you are touching that part of the image.

Either that or perhaps you are not returning true in your touch handler ? [import]uid: 84637 topic_id: 17009 reply_id: 64343[/import]

Did you use:

  1. Runtime:addEventListener( “touch”,OnObjectTouch)
    – or –
  2. object1:addEventListener(“touch”,OnObjectTouch)

Runtime:addEventListener would respond to any touch on the screen and not just touches within the boundaries of the graphic object. If not, and using option #2 the above comments from Peach or Danny might be correct; that the actual boundary of the object is larger than it appears or handler not returning true.

To debug you might replace your graphic object with code created object of absolute size:
object1 = display.newRect( 300, 300, 100, 100)
object1:setFillColor( 0, 0, 255 )

One other thought, are you correctly handling the touches by phase in your event handler?

-David
[import]uid: 96411 topic_id: 17009 reply_id: 64352[/import]