本文整理汇总了C#中FarseerPhysics.Common.Path.Translate方法的典型用法代码示例。如果您正苦于以下问题:C# Path.Translate方法的具体用法?C# Path.Translate怎么用?C# Path.Translate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FarseerPhysics.Common.Path
的用法示例。
在下文中一共展示了Path.Translate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PathTest
private PathTest()
{
//Single body that moves around path
_movingBody = BodyFactory.CreateBody(World);
_movingBody.Position = new Vector2(-25, 25);
_movingBody.BodyType = BodyType.Dynamic;
_movingBody.CreateFixture(new PolygonShape(PolygonTools.CreateRectangle(0.5f, 0.5f), 1));
//Static shape made up of bodies
_path = new Path();
_path.Add(new Vector2(0, 20));
_path.Add(new Vector2(5, 15));
_path.Add(new Vector2(20, 18));
_path.Add(new Vector2(15, 1));
_path.Add(new Vector2(-5, 14));
_path.Closed = true;
CircleShape shape = new CircleShape(0.25f, 1);
PathManager.EvenlyDistributeShapesAlongPath(World, _path, shape, BodyType.Static, 100);
//Smaller shape that is movable. Created from small rectangles and circles.
Vector2 xform = new Vector2(0.5f, 0.5f);
_path.Scale(ref xform);
xform = new Vector2(5, 5);
_path.Translate(ref xform);
List<Shape> shapes = new List<Shape>(2);
shapes.Add(new PolygonShape(PolygonTools.CreateRectangle(0.5f, 0.5f, new Vector2(-0.1f, 0), 0), 1));
shapes.Add(new CircleShape(0.5f, 1));
List<Body> bodies = PathManager.EvenlyDistributeShapesAlongPath(World, _path, shapes, BodyType.Dynamic, 20);
//Attach the bodies together with revolute joints
PathManager.AttachBodiesWithRevoluteJoint(World, bodies, new Vector2(0, 0.5f), new Vector2(0, -0.5f), true,
true);
xform = new Vector2(-25, 0);
_path.Translate(ref xform);
Body body = BodyFactory.CreateBody(World);
body.BodyType = BodyType.Static;
//Static shape made up of edges
PathManager.ConvertPathToEdges(_path, body, 25);
body.Position -= new Vector2(0, 10);
xform = new Vector2(0, 15);
_path.Translate(ref xform);
PathManager.ConvertPathToPolygon(_path, body, 1, 50);
}