Ich versuche, Schweißnähte für meine Box2D-Körper zu implementieren:
for(pos = _contactListener->_contacts.begin();
pos != _contactListener->_contacts.end(); ++pos) {
MyContact contact = *pos;
b2Body *bodyA = contact.fixtureA->GetBody();
b2Body *bodyB = contact.fixtureB->GetBody();
b2Vec2 worldCoordsAnchorPoint = bodyA->GetWorldPoint (b2Vec2(0,0));
b2WeldJointDef weldJointDef;
weldJointDef.bodyA = bodyA;
weldJointDef.bodyB = bodyB;
weldJointDef.localAnchorA = weldJointDef.bodyA->GetLocalPoint(worldCoordsAnchorPoint);
weldJointDef.localAnchorB = weldJointDef.bodyB->GetLocalPoint(worldCoordsAnchorPoint);
weldJointDef.referenceAngle = weldJointDef.bodyB->GetAngle() - weldJointDef.bodyA->GetAngle();
weldJointDef.collideConnected = true;
weldJointDef.userData = @"tile";
weldJointDef.Initialize(bodyA, bodyB, worldCoordsAnchorPoint);
world->CreateJoint(&weldJointDef);
//}
}
aber meine fps sind sehr niedrig. Ich denke, dass es daran liegt, dass ich nicht überprüfe, dass die Körper diejenigen sind, die geschweißt werden sollen. Wie kann ich überprüfen, ob die Körper verbunden sind? Vielen Dank.