public static Body CreatePolygon(World world, Vertices vertices, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, object userData = null) { Body body = CreateBody(world, position, rotation, bodyType, userData); FixtureFactory.AttachPolygon(vertices, density, body); return(body); }
public static Body CreateRectangle(World world, float width, float height, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, object userData = null) { if (width <= 0) { throw new ArgumentOutOfRangeException(nameof(width), "Width must be more than 0 meters"); } if (height <= 0) { throw new ArgumentOutOfRangeException(nameof(height), "Height must be more than 0 meters"); } Body body = CreateBody(world, position, rotation, bodyType, userData); Vertices rectangleVertices = PolygonUtils.CreateRectangle(width / 2, height / 2); FixtureFactory.AttachPolygon(rectangleVertices, density, body); return(body); }