public Body CreatePolygon(Vertices vertices, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static) { Body body = CreateBody(position, rotation, bodyType); body.CreatePolygon(vertices, density); return(body); }
public Body CreateRectangle(float width, float height, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static) { 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(position, rotation, bodyType); Vertices rectangleVertices = PolygonTools.CreateRectangle(width / 2, height / 2); body.CreatePolygon(rectangleVertices, density); return(body); }