to retrieve collision you have to:
a- call setupCollisionReport that enable the collision report between two object. Collision report is quite expensive if is done for every collision, so by default is disabled.
this is the function:
phManager.setupCollisionReport(actor1, actor2, flag, getForce);
actor1 and 2 are the two object that you want to get the collision, if you want to check the collision with the intere scene you have to call setupCollisionReport for every couple. :-S
flag can be:
- NOTIFY_ON_START_TOUCH: report is generated when the object start colliding
- NOTIFY_ON_TOUCH: report is generated in every step the object are in collision
- NOTIFY_ON_END_TOUCH: report is generated when the object stop colling
The last parameter is a boolean that tell the function to retrieve the collision force and
Then you have to create some collisionStruct to retrieve the collision value, i suggest you to create these collision only one time as global variable.
collisions = array(42);
for(var i = 0; i < 42; ++i)
collisions[i] = collisionStruct();
then you have to call
ret = phManager.getGlobalCollision(&collisions);
this function fill the collisions structs and return the number of collision occurred since the last call of this function.
The collision buffer is very limited so I suggest you to call the getGlobalColision every simulation step to not overflow it.
If the buffer is overflowed the first collision is overwritten, don't rely on the fact that after a START_COLLISION you always get a END_COLLISION.
Note: The collision are signaled only if they really occour, if two object of different collision group are touching you will get a collision point only if the collision are not disabled.
Don't abuse of these function because are quite slow (and the buffer is small).
I have attached some other demo to the post, you will find a demo called "Contatti" that you how to retrieve collision (I think you have to work a bit on the paths the make them works)