This project has moved. For the latest updates, please go here.

Destroying a LoopShape

Mar 2, 2011 at 2:04 AM

I'm having troubles to completely destroy it. I'm working on a level editor where i can load/save my current level.


Everything is working fine, including the deletion of other Fixtures (Rectangles) by simply calling fixture.dispose(), except for those LoopShapes. They still keep colliding with my character, even after loading another level, but won't draw (obviously, since the object is gone). I've also tried manually removing the body from my world (world.removebody(body)), using fixture.destroybody and settings all objects to null.


Here's the class I am using:

    public class VectorBox
        public Vertices v = new Vertices();
        public Fixture f;
        public Body b;

        public VectorBox(Vertices _v)
            v = _v;
            f = FixtureFactory.CreateLoopShape(, _v, 1);

            f.Body.BodyType = BodyType.Static;
            f.Body.SleepingAllowed = false;
            b = f.Body;

        public void Dispose()
            v = new Vertices();

Mar 4, 2011 at 8:23 PM

You don't keep a reference to the loopshape somewhere else? Calling RemoveBody() on the body with the loopshape should remove the loopshape.