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

Trying to destroy object

Topics: User Forum
Apr 15, 2011 at 4:30 AM

Hi all,

Sorry if this is a newbie question. I'm trying to destroy an object from code behind in Silverlight/Farseer physics/Physics Helper 4/C#.

I wrote this code:
            if (sprite1.Name.StartsWith("iObject") && sprite2.Name.StartsWith("eDestroy"))
                if (Math.Abs(sprite1.BodyObject.AngularVelocity) > 15) //if a "real" hit, regardless of direction

                    World.DestroyBody(sprite2); //doesn't work because "FarseerPhysics.Dynamics.World does not contain a definition for DestroyBody." 

                    sprite2.BodyObject.DestroyFixture(sprite2.BodyObject.FixtureList[0]); //another idea that I don't really know what it's doing

All I'm trying to do is to get the explodebehaviour to fire, so that I get these little particles and the object disappears, but I need to do it in code.

Thanks a lot for any replies!


Apr 16, 2011 at 10:16 PM

Use World.RemoveBody() to remove a body from the world.

Apr 18, 2011 at 11:29 PM