public BreakableBody(List<Vertices> vertices, World world, float density) { _world = world; MainBody = _world.CreateBody(); MainBody.BodyType = BodyType.Dynamic; foreach (Vertices part in vertices) { PolygonShape polygonShape = new PolygonShape(part); Fixture fixture = MainBody.CreateFixture(polygonShape, density); fixture.PostSolve += PostSolve; Parts.Add(fixture); } }
public static Body CreateBody(World world, Vector2 position) { Body body = world.CreateBody(); body.Position = position; return body; }
/// <summary> /// Duplicates the given Body along the given path for approximatly the given copies. /// </summary> /// <param name="world">The world.</param> /// <param name="path">The path.</param> /// <param name="shapes">The shapes.</param> /// <param name="type">The type.</param> /// <param name="copies">The copies.</param> /// <returns></returns> public static List<Body> EvenlyDistibuteShapesAlongPath(World world, Path path, IEnumerable<Shape> shapes, BodyType type, int copies, float density) { List<Vector3> centers = path.SubdivideEvenly(copies); List<Body> bodyList = new List<Body>(); Body b; for (int i = 0; i < centers.Count; i++) { b = world.CreateBody(); // copy the type from original body b.BodyType = type; b.Position = new Vector2(centers[i].X, centers[i].Y); b.Rotation = centers[i].Z; foreach (Shape shape in shapes) { b.CreateFixture(shape, density); } bodyList.Add(b); } return bodyList; }
public static Body CreateBody(World world) { Body body = world.CreateBody(); return body; }