Пример #1
0
        public Body CreateCircle(float radius, float density, Vector2 position = new Vector2(), BodyType bodyType = BodyType.Static)
        {
            Body body = CreateBody(position, 0, bodyType);

            body.CreateCircle(radius, density);
            return(body);
        }
Пример #2
0
        public Body CreateCapsule(float height, float endRadius, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static)
        {
            //Create the middle rectangle
            Vertices rectangle = PolygonTools.CreateRectangle(endRadius, height / 2);

            List <Vertices> list = new List <Vertices>();

            list.Add(rectangle);

            Body body = CreateCompoundPolygon(list, density, position, rotation, bodyType);

            body.CreateCircle(endRadius, density, new Vector2(0, height / 2));
            body.CreateCircle(endRadius, density, new Vector2(0, -(height / 2)));

            //Create the two circles
            //CircleShape topCircle = new CircleShape(endRadius, density);
            //topCircle.Position = new Vector2(0, height / 2);
            //body.CreateFixture(topCircle);

            //CircleShape bottomCircle = new CircleShape(endRadius, density);
            //bottomCircle.Position = new Vector2(0, -(height / 2));
            //body.CreateFixture(bottomCircle);
            return(body);
        }