Initialize() public method

public Initialize ( Body body1, Body body2, System.Vector2 groundAnchor1, System.Vector2 groundAnchor2, System.Vector2 anchor1, System.Vector2 anchor2, float ratio ) : void
body1 Body
body2 Body
groundAnchor1 System.Vector2
groundAnchor2 System.Vector2
anchor1 System.Vector2
anchor2 System.Vector2
ratio float
return void
Beispiel #1
0
		public Pulleys()
		{
			Body ground = null;
			{
				PolygonDef sd = new PolygonDef();
				sd.SetAsBox(50.0f, 10.0f);

				BodyDef bd = new BodyDef();
				bd.Position.Set(0.0f, -10.0f);
				ground = _world.CreateBody(bd);
				ground.CreateShape(sd);
			}

			{
				float a = 2.0f;
				float b = 4.0f;
				float y = 16.0f;
				float L = 12.0f;

				PolygonDef sd = new PolygonDef();
				sd.SetAsBox(a, b);
				sd.Density = 5.0f;

				BodyDef bd = new BodyDef();

				bd.Position.Set(-10.0f, y);
				Body body1 = _world.CreateBody(bd);
				body1.CreateShape(sd);
				body1.SetMassFromShapes();

				bd.Position.Set(10.0f, y);
				Body body2 = _world.CreateBody(bd);
				body2.CreateShape(sd);
				body2.SetMassFromShapes();

				PulleyJointDef pulleyDef = new PulleyJointDef();
				Vec2 anchor1 = new Vec2(-10.0f, y + b);
				Vec2 anchor2 = new Vec2(10.0f, y + b);
				Vec2 groundAnchor1 = new Vec2(-10.0f, y + b + L);
				Vec2 groundAnchor2 = new Vec2(10.0f, y + b + L);
				pulleyDef.Initialize(body1, body2, groundAnchor1, groundAnchor2, anchor1, anchor2, 2.0f);

				_joint1 = (PulleyJoint)_world.CreateJoint(pulleyDef);
			}
		}
Beispiel #2
0
        public Pulleys()
        {
            Body ground = null;
            {
                BodyDef bd = new BodyDef();
                ground = _world.CreateBody(bd);

                PolygonShape shape = new PolygonShape();
                shape.SetAsEdge(new Vec2(-40.0f, 0.0f), new Vec2(40.0f, 0.0f));
                ground.CreateFixture(shape, 0);
            }

            {
                float a = 2.0f;
                float b = 4.0f;
                float y = 16.0f;
                float L = 12.0f;

                PolygonShape shape = new PolygonShape();
                shape.SetAsBox(a, b);

                BodyDef bd = new BodyDef();

                bd.Position.Set(-10.0f, y);
                Body body1 = _world.CreateBody(bd);
                body1.CreateFixture(shape, 5.0f);

                bd.Position.Set(10.0f, y);
                Body body2 = _world.CreateBody(bd);
                body2.CreateFixture(shape, 5.0f);

                PulleyJointDef pulleyDef = new PulleyJointDef();
                Vec2 anchor1 = new Vec2(-10.0f, y + b);
                Vec2 anchor2 = new Vec2(10.0f, y + b);
                Vec2 groundAnchor1 = new Vec2(-10.0f, y + b + L);
                Vec2 groundAnchor2 = new Vec2(10.0f, y + b + L);
                pulleyDef.Initialize(body1, body2, groundAnchor1, groundAnchor2, anchor1, anchor2, 2.0f);

                _joint1 = (PulleyJoint)_world.CreateJoint(pulleyDef);
            }
        }