Not Touching 2 objects at once.

Hello fellow Corona-roonies.

I’m having a small issue.

lets say i have a background & a button.

When you press the button it prints(“Yay”).

When you touch the background it follows your touch throughout the “moved” phase.

My problem is if i touch the button, both the “Yay” and the backgrounds phases’ will happen.
I want to make it so if you touch the button, your touch doesnt go through and touch the BG too.
How would i go about this?

the Button and BG are just display objects not physics objects.
Thanks,
Matt [import]uid: 91798 topic_id: 16005 reply_id: 316005[/import]

Hi there,
I think you just put “return true” as the last line in the function which is triggered by your button touch. This tells Corona to stop listening for further touch events and process only the button touch. It’s been awhile since I did this, so I don’t vouch 100% for it, but perhaps somebody else can confirm this is correct…

local function buttonTouch( event )  
  
 --(YOUR CODE HERE)  
 return true  
  
end  

Brent Sorrentino
Ignis Design [import]uid: 9747 topic_id: 16005 reply_id: 59377[/import]

I know the solution was pretty small but the problem was quite big gameplay wise.

And your solution worked!
Not only that, it also fixed another issue i was having where you could press 2 buttons at the same time since they overlap slightly!

And i’m so happy!

http://media.ebaumsworld.com/picture/Short_Yeti/EpicHighFive.png

Thanks Ignis! [import]uid: 91798 topic_id: 16005 reply_id: 59386[/import]

ED?T: OK! I TRY AGAIN AND FIX IT…

I have two circle. I try ‘return true’ but I cannot touch two buttons at the sametime

[code]
function tapFor1( event )
some code…
return true
end

function tapFor2( event )
some code…
return true
end

btn1:addEventListener( “touch”, tapFor1 )
btn2:addEventListener( “touch”, tapFor2 )
[/code] [import]uid: 51730 topic_id: 16005 reply_id: 59474[/import]

Hey, are you saying you WANT to touch two buttons at once? If so do not use return true and make sure that multitouch is enabled. [import]uid: 52491 topic_id: 16005 reply_id: 59697[/import]