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;
 _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));

 groundBox.Set(b2Vec2(0, s.height/PTM_RATIO), b2Vec2(s.width/PTM_RATIO,

 groundBox.Set(b2Vec2(s.width/PTM_RATIO, s.height/PTM_RATIO),
 b2Vec2(s.width/PTM_RATIO, 0));

Here is the code for the prismatic joint itself

b2PrismaticJointDef jointDef;
b2Vec2 worldAxis(1.0f,0.0f);
jointDef.collideConnected = true;
                    _shipBody->GetWorldCenter(), worldAxis);
  • \$\begingroup\$ Read this and you'll be able to answer your own question. -1 for lack of research and no debugging effort. \$\endgroup\$
    – House
    Mar 11, 2014 at 20:54
  • 1
    \$\begingroup\$ I dont believe the down vote is deserved since 1.) Im using C++, 2.) this has nothing to do with removing objects. 3.) The solution was to actually move the boundary method after the world was created since it was crashing on the _world->createFixture method since the world hadn't been created at that point. \$\endgroup\$ Mar 11, 2014 at 20:59
  • \$\begingroup\$ I didn't say the questions were the same, however the underlying problems are very similar. Both could easily be solved by reading the error message, and debugging. Further, searching for "Assertion failed: (IsLocked() == false), function CreateBody" returns a number of results for how to solve the problem (thus lack of research). \$\endgroup\$
    – House
    Mar 11, 2014 at 21:04


You must log in to answer this question.

Browse other questions tagged .