I expect a display object that has physics added to it(addBody) to provide me a table of objects it's touching, but it doesn't.
Is there a simple mechanism for getting a table of all the other objects that my display object is touching? Or do I have to keep track of them during collision events?
Edit for clarity: I looked into region queries, the problem is I need each object to be accessible recursively. Think of the game Bejeweled. If I have a ton of physics objects falling to the 'ground', and a few of them share like-properties (like colors in Bejeweled), I'd like to know which of those 5 physics objects are touching all at the same time. And if x or more are touching, I'd like to remove the objects from the game at the same time.
So if A is touching B and C, and A B & C all share the same color, remove them all at once. But perhaps A & B have come to rest for a while before C shows up. There's no real easy way to check the state of A, if C collides into B. How can I see if C, B, and A objects all connect with one another, are still touching, and all share a like property so I can make them disappear?
I tried adding a property to my falling objects, and then on a collision event, seeing if the event.other.color matches my self.color. And if they do, then I add them to another table indicating they're currently touching.
But my method of keeping track of what is "touching" only works until the event.phase == "ended". When that happens, I remove the data from the table. Unfortunately something happens here where things don't always get registered as "no longer touching". I think it's a sign that my method isn't working really well.
I can't be the first to want to do something like this, but how is everyone else doing it? Where have I gone wrong?