listen for touch "began" on one object and listen for touch "ended" on another.

What I'm doing is have a load of physics bodies create themselves when the screen is touched but I want to listen for a release or touch ended on those objects that were just created.
The objects are created in a touch listener function for the background. So when the user touches the screen some objects are created and I want to check if any of those happen to be under the users finger.

The problem is when I create a touch listener on those newly created objects they wont receive the touch event because they were created just after the touch event I want to listen for.

Any suggestions would be much appreciated. ps I'm a novice.

Are you going to try to capture the touch/release event for each object such that when there is a release, you know this object has been touched a moment ago?

Maybe you can try to do a touch capture of Runtime scope and compare event.x,y with each object?

Another workaround is to create another small isSensor physics object under the finger and so this object will collide with the underlying objects immediately. Hope it helps.

Keep an enterFrame listener running to examine recently created objects. When you create new objects, log them in a global table, along with some timestamp or frame_id about when (in which enterframe pass) they were created.

When your enterFrame listener sees newly (created in the LAST enterFrame event) objecs, it will dispatch a touch event to each of them

Hope that helps

dgaedcke, please could you explain this idea, I'm not entirely sure what you mean but it sounds promising.

Sorry I logged in to the forum as the wrong user (dot is me too)...
Please could you explain this idea, I'm not entirely sure what you mean but it sounds promising.

Help me help you...I'm not willing to write a descrip of every Corona feature mentioned in my suggestion....if you have specific questions about some part of my suggestion you don't understand, ask that and I'll try to clarify the part that is confusing. Just please make sure you're not asking me to teach you things you could have read in the Corona docs...

If anyone's interested I've solved the problem using a temporary 1px object which just exists between the began and ended phases of the touch event and listens for collisions. I'd tried this before but it wasn't working because I'd set it to be a static physics body.. It needed to be dynamic with a temporary joint to the touch event.

views:1942 update:2011/10/3 8:06:12
corona forums © 2003-2011