Exemplo n.º 1
0
        public static Body CreateRectangle(World world, FP width, FP height, FP density, TSVector2 position, object userData = null)
        {
            bool flag = width <= 0;

            if (flag)
            {
                throw new ArgumentOutOfRangeException("width", "Width must be more than 0 meters");
            }
            bool flag2 = height <= 0;

            if (flag2)
            {
                throw new ArgumentOutOfRangeException("height", "Height must be more than 0 meters");
            }
            Body body = BodyFactory.CreateBody(world, position);

            body.UserData = userData;
            Vertices     vertices = PolygonTools.CreateRectangle(width / 2, height / 2);
            PolygonShape shape    = new PolygonShape(vertices, density);

            body.CreateFixture(shape, null);
            return(body);
        }
Exemplo n.º 2
0
        public static Body CreateRectangle(World world, FP width, FP height, FP density, TSVector2 position, object userData = null)
        {
            if (width <= 0)
            {
                throw new ArgumentOutOfRangeException("width", "Width must be more than 0 meters");
            }

            if (height <= 0)
            {
                throw new ArgumentOutOfRangeException("height", "Height must be more than 0 meters");
            }

            Body newBody = CreateBody(world, position);

            newBody.UserData = userData;

            Vertices     rectangleVertices = PolygonTools.CreateRectangle(width / 2, height / 2);
            PolygonShape rectangleShape    = new PolygonShape(rectangleVertices, density);

            newBody.CreateFixture(rectangleShape);

            return(newBody);
        }
Exemplo n.º 3
0
 public static Vertices CreateCircle(FP radius, int numberOfEdges)
 {
     return(PolygonTools.CreateEllipse(radius, radius, numberOfEdges));
 }