public virtual void DoRemoveBody(CCPhysicsBody body) { cp.AssertWarn(body != null, "the body can not be nullptr"); // reset the gravity if (!body.IsGravityEnabled()) { body.ApplyForce(_gravity * body.GetMass()); } // remove shaps foreach (var shape in body.GetShapes()) { RemoveShape(shape); } // remove body _info.removeBody(body._info); }
public virtual void DoAddBody(CCPhysicsBody body) { if (body.IsEnabled()) { //is gravity enable if (!body.IsGravityEnabled()) { body.ApplyForce(-_gravity * body.GetMass()); } // add body to space if (body.IsDynamic()) { _info.addBody(body._info); } // add shapes to space foreach (CCPhysicsShape shape in body.GetShapes()) { AddShape(shape); } } }