本文整理汇总了C#中FarseerPhysics.Dynamics.World.CreateBody方法的典型用法代码示例。如果您正苦于以下问题:C# World.CreateBody方法的具体用法?C# World.CreateBody怎么用?C# World.CreateBody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FarseerPhysics.Dynamics.World
的用法示例。
在下文中一共展示了World.CreateBody方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BreakableBody
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);
}
}
示例2: CreateBody
public static Body CreateBody(World world, Vector2 position)
{
Body body = world.CreateBody();
body.Position = position;
return body;
}
示例3: EvenlyDistibuteShapesAlongPath
/// <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;
}