public LineJoint() { Body ground = null; { PolygonShape shape = new PolygonShape(); shape.SetAsEdge(new Vector2(-40.0, 0.0), new Vector2(40.0, 0.0)); BodyDef bd = new BodyDef(); ground = _world.CreateBody(bd); ground.CreateFixture(shape, 0.0); } { PolygonShape shape = new PolygonShape(); shape.SetAsBox(0.5, 2.0); BodyDef bd = new BodyDef(); bd.type = BodyType.Dynamic; bd.position = new Vector2(0.0, 7.0); Body body = _world.CreateBody(bd); body.CreateFixture(shape, 1.0); LineJointDef jd = new LineJointDef(); Vector2 axis = new Vector2(2.0, 1.0); axis.Normalize(); jd.Initialize(ground, body, new Vector2(0.0, 8.5), axis); jd.motorSpeed = 0.0; jd.maxMotorForce = 100.0; jd.enableMotor = true; jd.lowerTranslation = -4.0; jd.upperTranslation = 4.0; jd.enableLimit = true; _world.CreateJoint(jd); } }
public LineJoint() { Body ground = null; { PolygonShape shape = new PolygonShape(); shape.SetAsEdge(new Vector2(-40.0f, 0.0f), new Vector2(40.0f, 0.0f)); BodyDef bd = new BodyDef(); ground = _world.CreateBody(bd); ground.CreateFixture(shape, 0.0f); } { PolygonShape shape = new PolygonShape(); shape.SetAsBox(0.5f, 2.0f); BodyDef bd = new BodyDef(); bd.type = BodyType.Dynamic; bd.position = new Vector2(0.0f, 7.0f); Body body = _world.CreateBody(bd); body.CreateFixture(shape, 1.0f); LineJointDef jd = new LineJointDef(); Vector2 axis = new Vector2(2.0f, 1.0f); axis.Normalize(); jd.Initialize(ground, body, new Vector2(0.0f, 8.5f), axis); jd.motorSpeed = 0.0f; jd.maxMotorForce = 100.0f; jd.enableMotor = true; jd.lowerTranslation = -4.0f; jd.upperTranslation = 4.0f; jd.enableLimit = true; _world.CreateJoint(jd); } }
public LineJoint() { Body ground = null; { PolygonShape shape = new PolygonShape(); shape.SetAsEdge(new Vec2(-40.0f, 0.0f), new Vec2(40.0f, 0.0f)); BodyDef bd = new BodyDef(); ground = m_world.CreateBody(bd); ground.CreateFixture(shape, 0.0f); } { PolygonShape shape = new PolygonShape(); shape.SetAsBox(0.5f, 2.0f); BodyDef bd = new BodyDef(); bd.BodyType = BodyType.Dynamic; bd.Position = new Vec2(0.0f, 7.0f); Body body = m_world.CreateBody(bd); body.CreateFixture(shape, 1.0f); LineJointDef jd = new LineJointDef(); Vec2 axis = new Vec2(2.0f, 1.0f); axis.Normalize(); jd.Initialize(ground, body, new Vec2(0.0f, 8.5f), axis); jd.MotorSpeed = 0.0f; jd.MaxMotorForce = 100.0f; jd.EnableMotor = true; jd.LowerTranslation = -4.0f; jd.UpperTranslation = 4.0f; jd.EnableLimit = true; m_world.CreateJoint(jd); } }
public LineJoint() { 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.CreateFixture(sd); } { PolygonDef sd = new PolygonDef(); sd.SetAsBox(0.5f, 2.0f); sd.Density = 1.0f; BodyDef bd = new BodyDef(); bd.Position.Set(0.0f, 7.0f); Body body = _world.CreateBody(bd); body.CreateFixture(sd); body.SetMassFromShapes(); LineJointDef jd = new LineJointDef(); Vec2 axis = new Vec2(2.0f, 1.0f); axis.Normalize(); jd.Initialize(ground, body, new Vec2(0.0f, 8.5f), axis); jd.motorSpeed = 0.0f; jd.maxMotorForce = 100.0f; jd.enableMotor = true; jd.lowerTranslation = -4.0f; jd.upperTranslation = 4.0f; jd.enableLimit = true; _world.CreateJoint(jd); } }