Closed mihai-moldovan closed 5 years ago
In case I want to reinitialise the world and I call ofxBox2d.init() again after setting the ground, the framework will crash.
Proposed fix in ofBox2d.init(): first destroy the ground, then delete the world: if(ground!=NULL) { world->DestroyBody(ground); ground = NULL; }
delete world; world = NULL; world = new b2World(b2Vec2(gravity.x, gravity.y)); world->SetAllowSleeping(doSleep); //world->SetDebugDraw(&debugRender);
In case I want to reinitialise the world and I call ofxBox2d.init() again after setting the ground, the framework will crash.
Proposed fix in ofBox2d.init(): first destroy the ground, then delete the world: if(ground!=NULL) { world->DestroyBody(ground); ground = NULL; }
delete world; world = NULL; world = new b2World(b2Vec2(gravity.x, gravity.y)); world->SetAllowSleeping(doSleep); //world->SetDebugDraw(&debugRender);