I have collision detection in my game. Now I need point of collison. I get it with:
int numPoints = contact.b2contact->GetManifold()->pointCount;
b2WorldManifold worldManifold;
contact.b2contact->GetWorldManifold( &worldManifold );
for (int i = 0; i < numPoints; i++)
{
NSLog(@"%@" NSStringFormCGPoint(ccp(worldManifold.points[i].x,worldManifold.points[i].y));
}
This log shows position but in box2d standards. How I should properly convert it to Cocos2d v2 cords? Because multiply by PTM_RATIO not working very well.
UPDATE
At this moment I came up with this.
b2Manifold* mainfold = contact->GetManifold();
int numPoints = mainfold->pointCount;
for (int i=0; i<numPoints; i++) {
b2ManifoldPoint *p = mainfold->points;
NSLog(@"Dot:%@",NSStringFromCGPoint(ccp(p->localPoint.x * PTM_RATIO, p->localPoint.y * PTM_RATIO);));
}
But that shows correct point only for one body.