public subdivideEvenly ( int divisions ) : List |
||
divisions | int | |
Résultat | List |
/// <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> /// <param name="userData"></param> /// <returns></returns> public static List <Body> evenlyDistributeShapesAlongPath(World world, Path path, IEnumerable <Shape> shapes, BodyType type, int copies, object userData = null) { List <Vector3> centers = path.subdivideEvenly(copies); List <Body> bodyList = new List <Body>(); for (int i = 0; i < centers.Count; i++) { Body b = new Body(world); // copy the type from original body b.bodyType = type; b.position = new Vector2(centers[i].X, centers[i].Y); b.rotation = centers[i].Z; b.userData = userData; foreach (Shape shape in shapes) { b.createFixture(shape); } bodyList.Add(b); } return(bodyList); }
/// <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> /// <param name="userData"></param> /// <returns></returns> public static List<Body> evenlyDistributeShapesAlongPath( World world, Path path, IEnumerable<Shape> shapes, BodyType type, int copies, object userData = null ) { List<Vector3> centers = path.subdivideEvenly( copies ); List<Body> bodyList = new List<Body>(); for( int i = 0; i < centers.Count; i++ ) { Body b = new Body( world ); // copy the type from original body b.bodyType = type; b.position = new Vector2( centers[i].X, centers[i].Y ); b.rotation = centers[i].Z; b.userData = userData; foreach( Shape shape in shapes ) { b.createFixture( shape ); } bodyList.Add( b ); } return bodyList; }