Hi guys, I have some strange problem with my game which uses Box2D as physics engine and I'm out of ideas on what I can do to solve it.
My game is a class assignment where I need to build a simple game where the main character moves in a 2D environment while square blocks comes from below him. Each time a collision occurs, that block is attached to the character using a weld joint, when three blocks of the same colors are together, they annihilate themselves(an effect similar to Bejeweled). I'm using a recursive function to iterate through all the attached blocks of a given block to see if there are enough blocks for them to be deleted.
I'm using GetContactList function to iterate through the list of contacts to see which blocks are adjacent to each other. The results are quite disappointing, the blocks only get annihilated in few cases. After a lot of debugging, I found the issue, but I still don't know how to solve.
My issue is: after some time, GetContactList STOPS returning contacts (return NULL) to blocks that were already attached for some time
. I spent some time reading the Box2D manual as well as some tutorials and still didn't find any clue of what is happening.
Below there's some simplified version of the code that I wrote.
for(int a = 0; a < blocksList.size(); a++)
And on BuildConnections
b2ContactEdge* edge = body->GetContactList();
while(edge != NULL)
//if there's, call BuildConnections again on the adjacent block
edge = edge->next;
I know that there's another issue related to circular inclusions, but I fairly sure that this problem isn't causing the problem with the collisions.
You can download my entire code from this page if you'd like http://code.google.com/p/fellz/source/list