本文整理汇总了C#中FarseerPhysics.Common.Path.SubdivideEvenly方法的典型用法代码示例。如果您正苦于以下问题:C# Path.SubdivideEvenly方法的具体用法?C# Path.SubdivideEvenly怎么用?C# Path.SubdivideEvenly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FarseerPhysics.Common.Path
的用法示例。
在下文中一共展示了Path.SubdivideEvenly方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EvenlyDistributeShapesAlongPath
/// <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, DebugMaterial userData)
{
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;
foreach (Shape shape in shapes)
{
b.CreateFixture(shape, userData);
}
bodyList.Add(b);
}
return bodyList;
}
示例2: AddCrates
private void AddCrates()
{
// Define a path that gives the placements of the crates
var cratesPath = new Path();
cratesPath.Add(new Vector2(160, 1000));
cratesPath.Add(new Vector2(3500, 1000));
// Split the path into 30 positions - this is where the crates go
var positions = cratesPath
.SubdivideEvenly(30)
.Select(v3 => new Vector2(v3.X, v3.Y));
foreach (var position in positions)
{
var crate = new Crate(this) { Position = position };
_crates.Add(crate);
_allGameOjbects.Add(crate);
}
}