I tried to set up a prismatic joint, but I get this error upon run time: Assertion failed: (IsLocked() == false), function CreateBody, file /Users/Aether/Developer/JFRecode/JFRecode/libs/Box2D/Dynamics/b2World.cpp, line 109.
Here is the code for the screen boundaries since I am using it as bodyB.
CGSize s = [CCDirector sharedDirector].winSize;
//define screen boundaries
// Create edges around the entire screen
b2BodyDef groundBodyDef;
groundBodyDef.position.Set(0,0);
_groundBody = _world->CreateBody(&groundBodyDef);
b2EdgeShape groundBox;
b2FixtureDef groundBoxDef;
groundBoxDef.shape = &groundBox;
groundBox.Set(b2Vec2(0,0), b2Vec2(s.width/PTM_RATIO, 0));
_bottomFixture = _groundBody->CreateFixture(&groundBoxDef);
groundBox.Set(b2Vec2(0,0), b2Vec2(0, s.height/PTM_RATIO));
_groundBody->CreateFixture(&groundBoxDef);
groundBox.Set(b2Vec2(0, s.height/PTM_RATIO), b2Vec2(s.width/PTM_RATIO,
s.height/PTM_RATIO));
_groundBody->CreateFixture(&groundBoxDef);
groundBox.Set(b2Vec2(s.width/PTM_RATIO, s.height/PTM_RATIO),
b2Vec2(s.width/PTM_RATIO, 0));
_groundBody->CreateFixture(&groundBoxDef);
Here is the code for the prismatic joint itself
b2PrismaticJointDef jointDef;
b2Vec2 worldAxis(1.0f,0.0f);
jointDef.collideConnected = true;
jointDef.Initialize(_shipBody,_groundBody,
_shipBody->GetWorldCenter(), worldAxis);
_world->CreateJoint(&jointDef);
isLocked indicates that the physics world is being updated. That means you're running this code during the world step method, likely in or as a result of a contact callback method. Delay executing this code until after the world step.