Java 类com.badlogic.gdx.physics.box2d.joints.PrismaticJoint 实例源码

项目:cgc-game    文件:BodyFactory.java   
public void summonTrain(int curMap) 
{
    int dir = 150;
    TrainCar te = getCurrentTrain(curMap).get(0);

    if (!te.directionReversed())
    {
        dir = -150;         
    }

    int shinkansen = 2500;

    for(int i = 0; i < 3; i++)
    {
        PrismaticJoint pj = ((PrismaticJoint)cars.get(curMap*3+i));

        if (CGCWorld.getRandom().nextInt(10000) < 3)
        {
            pj.setMaxMotorForce(shinkansen);
        }
        else
        {
            pj.setMaxMotorForce(450);
        }
        pj.setMotorSpeed(dir);
        pj.enableMotor(true);
    }
}
项目:DreamsLibGdx    文件:CheckPointManager.java   
@Override
public void handleBeginContact(Contact contact) {
    CheckPoint checkPoint = getCheckPoint(contact);
    Hero hero = getHero(contact);
    Gdx.app.log(Constants.LOG, "Begin Contact CheckPoint");
    if (hero != null && checkPoint != null) {
        Gdx.app.log(Constants.LOG, "Begin Contact CheckPoint TRUE");
        ((PrismaticJoint) checkPoint.getJoint()).enableMotor(true);
    }
}
项目:DreamsLibGdx    文件:CheckPointManager.java   
@Override
public void update(float delta, Box2DPhysicsObject entity) {
    CheckPoint checkPoint= (CheckPoint) entity;
    if(((PrismaticJoint) checkPoint.getJoint()).getJointTranslation()>((PrismaticJoint) checkPoint.getJoint()).getUpperLimit())
        BaseGame.setGameState(GameState.GAME_LEVELWIN);

}
项目:evilrain    文件:Trigger.java   
@Override
public void createPhysicsActor(ParticleSystem particleSystem, World physicsWorld) {
    super.createPhysicsActor(particleSystem, physicsWorld);
    pos.sub(getWidth() / 2, getHeight() / 2);

    PolygonShape polygonShape = new PolygonShape();
    polygonShape.setAsBox(getPhysicsWidth() / 2, getPhysicsHeight() / 2.4f,
            new Vector2(0, getPhysicsHeight() / -15f), 0);

    offset.set(-getWidth() / 2, -getHeight() / 2);
    sprite.setOrigin(getWidth() / 2, getHeight() / 2);

    FixtureDef fixtureDef = new FixtureDef();
    fixtureDef.shape = polygonShape;
    fixtureDef.density = 1;
    fixtureDef.friction = 10.4f;

    BodyDef bodyDef = new BodyDef();
    bodyDef.position.set(pos.cpy().scl(GameWorld.WORLD_TO_BOX));
    bodyDef.type = bodyType != null ? bodyType : BodyDef.BodyType.DynamicBody;
    body = physicsWorld.createBody(bodyDef);
    body.createFixture(fixtureDef);
    body.resetMassData();

    polygonShape.dispose();

    polygonShape = new PolygonShape();
    polygonShape.setAsBox(getPhysicsWidth() / 3, getPhysicsHeight() / 20f);

    offset.set(-getWidth() / 2, -getHeight() / 2);
    sprite.setOrigin(getWidth() / 2, getHeight() / 2);

    fixtureDef = new FixtureDef();
    fixtureDef.shape = polygonShape;
    fixtureDef.density = 1;
    fixtureDef.friction = 10.4f;

    bodyDef = new BodyDef();
    bodyDef.position.set(pos.cpy().add(0, getHeight() / 2.5f).scl(GameWorld.WORLD_TO_BOX));
    bodyDef.type = BodyDef.BodyType.DynamicBody;
    topBody = physicsWorld.createBody(bodyDef);
    topBody.createFixture(fixtureDef);
    topBody.resetMassData();

    polygonShape.dispose();

    PrismaticJointDef jointDef = new PrismaticJointDef();
    jointDef.initialize(body, topBody,
            pos.cpy().scl(GameWorld.WORLD_TO_BOX), new Vector2(0.0f, 1.0f));
    jointDef.enableLimit = true;
    jointDef.upperTranslation = 0.02f;
    //jointDef.referenceAngle = 1;
    jointDef.collideConnected = true;
    jointDef.enableMotor = true;
    jointDef.motorSpeed = 2f;
    jointDef.maxMotorForce = 2f;
    distanceJoint = (PrismaticJoint)physicsWorld.createJoint(jointDef);

    setRotation(rot);
}
项目:flixel-gdx-box2d    文件:B2FlxPrismaticJoint.java   
@Override
public PrismaticJoint getJoint(){return (PrismaticJoint)joint;}
项目:DreamsLibGdx    文件:CheckPointManager.java   
private void enableMotor(CheckPoint checkPoint) {
    ((PrismaticJoint) checkPoint.getJoint()).enableMotor(true);
}
项目:DreamsLibGdx    文件:CheckPointManager.java   
private void disableMotor(CheckPoint checkPoint) {
    ((PrismaticJoint) checkPoint.getJoint()).enableMotor(false);
}
项目:ingress-indonesia-dev    文件:World.java   
private long createProperJoint(JointDef paramJointDef)
{
  if (paramJointDef.type == JointDef.JointType.DistanceJoint)
  {
    DistanceJointDef localDistanceJointDef = (DistanceJointDef)paramJointDef;
    return jniCreateDistanceJoint(this.addr, localDistanceJointDef.bodyA.addr, localDistanceJointDef.bodyB.addr, localDistanceJointDef.collideConnected, localDistanceJointDef.localAnchorA.x, localDistanceJointDef.localAnchorA.y, localDistanceJointDef.localAnchorB.x, localDistanceJointDef.localAnchorB.y, localDistanceJointDef.length, localDistanceJointDef.frequencyHz, localDistanceJointDef.dampingRatio);
  }
  if (paramJointDef.type == JointDef.JointType.FrictionJoint)
  {
    FrictionJointDef localFrictionJointDef = (FrictionJointDef)paramJointDef;
    return jniCreateFrictionJoint(this.addr, localFrictionJointDef.bodyA.addr, localFrictionJointDef.bodyB.addr, localFrictionJointDef.collideConnected, localFrictionJointDef.localAnchorA.x, localFrictionJointDef.localAnchorA.y, localFrictionJointDef.localAnchorB.x, localFrictionJointDef.localAnchorB.y, localFrictionJointDef.maxForce, localFrictionJointDef.maxTorque);
  }
  if (paramJointDef.type == JointDef.JointType.GearJoint)
  {
    GearJointDef localGearJointDef = (GearJointDef)paramJointDef;
    return jniCreateGearJoint(this.addr, localGearJointDef.bodyA.addr, localGearJointDef.bodyB.addr, localGearJointDef.collideConnected, localGearJointDef.joint1.addr, localGearJointDef.joint2.addr, localGearJointDef.ratio);
  }
  if (paramJointDef.type == JointDef.JointType.MouseJoint)
  {
    MouseJointDef localMouseJointDef = (MouseJointDef)paramJointDef;
    return jniCreateMouseJoint(this.addr, localMouseJointDef.bodyA.addr, localMouseJointDef.bodyB.addr, localMouseJointDef.collideConnected, localMouseJointDef.target.x, localMouseJointDef.target.y, localMouseJointDef.maxForce, localMouseJointDef.frequencyHz, localMouseJointDef.dampingRatio);
  }
  if (paramJointDef.type == JointDef.JointType.PrismaticJoint)
  {
    PrismaticJointDef localPrismaticJointDef = (PrismaticJointDef)paramJointDef;
    return jniCreatePrismaticJoint(this.addr, localPrismaticJointDef.bodyA.addr, localPrismaticJointDef.bodyB.addr, localPrismaticJointDef.collideConnected, localPrismaticJointDef.localAnchorA.x, localPrismaticJointDef.localAnchorA.y, localPrismaticJointDef.localAnchorB.x, localPrismaticJointDef.localAnchorB.y, localPrismaticJointDef.localAxisA.x, localPrismaticJointDef.localAxisA.y, localPrismaticJointDef.referenceAngle, localPrismaticJointDef.enableLimit, localPrismaticJointDef.lowerTranslation, localPrismaticJointDef.upperTranslation, localPrismaticJointDef.enableMotor, localPrismaticJointDef.maxMotorForce, localPrismaticJointDef.motorSpeed);
  }
  if (paramJointDef.type == JointDef.JointType.PulleyJoint)
  {
    PulleyJointDef localPulleyJointDef = (PulleyJointDef)paramJointDef;
    return jniCreatePulleyJoint(this.addr, localPulleyJointDef.bodyA.addr, localPulleyJointDef.bodyB.addr, localPulleyJointDef.collideConnected, localPulleyJointDef.groundAnchorA.x, localPulleyJointDef.groundAnchorA.y, localPulleyJointDef.groundAnchorB.x, localPulleyJointDef.groundAnchorB.y, localPulleyJointDef.localAnchorA.x, localPulleyJointDef.localAnchorA.y, localPulleyJointDef.localAnchorB.x, localPulleyJointDef.localAnchorB.y, localPulleyJointDef.lengthA, localPulleyJointDef.lengthB, localPulleyJointDef.ratio);
  }
  if (paramJointDef.type == JointDef.JointType.RevoluteJoint)
  {
    RevoluteJointDef localRevoluteJointDef = (RevoluteJointDef)paramJointDef;
    return jniCreateRevoluteJoint(this.addr, localRevoluteJointDef.bodyA.addr, localRevoluteJointDef.bodyB.addr, localRevoluteJointDef.collideConnected, localRevoluteJointDef.localAnchorA.x, localRevoluteJointDef.localAnchorA.y, localRevoluteJointDef.localAnchorB.x, localRevoluteJointDef.localAnchorB.y, localRevoluteJointDef.referenceAngle, localRevoluteJointDef.enableLimit, localRevoluteJointDef.lowerAngle, localRevoluteJointDef.upperAngle, localRevoluteJointDef.enableMotor, localRevoluteJointDef.motorSpeed, localRevoluteJointDef.maxMotorTorque);
  }
  if (paramJointDef.type == JointDef.JointType.WeldJoint)
  {
    WeldJointDef localWeldJointDef = (WeldJointDef)paramJointDef;
    return jniCreateWeldJoint(this.addr, localWeldJointDef.bodyA.addr, localWeldJointDef.bodyB.addr, localWeldJointDef.collideConnected, localWeldJointDef.localAnchorA.x, localWeldJointDef.localAnchorA.y, localWeldJointDef.localAnchorB.x, localWeldJointDef.localAnchorB.y, localWeldJointDef.referenceAngle);
  }
  if (paramJointDef.type == JointDef.JointType.RopeJoint)
  {
    RopeJointDef localRopeJointDef = (RopeJointDef)paramJointDef;
    return jniCreateRopeJoint(this.addr, localRopeJointDef.bodyA.addr, localRopeJointDef.bodyB.addr, localRopeJointDef.collideConnected, localRopeJointDef.localAnchorA.x, localRopeJointDef.localAnchorA.y, localRopeJointDef.localAnchorB.x, localRopeJointDef.localAnchorB.y, localRopeJointDef.maxLength);
  }
  if (paramJointDef.type == JointDef.JointType.WheelJoint)
  {
    WheelJointDef localWheelJointDef = (WheelJointDef)paramJointDef;
    return jniCreateWheelJoint(this.addr, localWheelJointDef.bodyA.addr, localWheelJointDef.bodyB.addr, localWheelJointDef.collideConnected, localWheelJointDef.localAnchorA.x, localWheelJointDef.localAnchorA.y, localWheelJointDef.localAnchorB.x, localWheelJointDef.localAnchorB.y, localWheelJointDef.localAxisA.x, localWheelJointDef.localAxisA.y, localWheelJointDef.enableMotor, localWheelJointDef.maxMotorTorque, localWheelJointDef.motorSpeed, localWheelJointDef.frequencyHz, localWheelJointDef.dampingRatio);
  }
  return 0L;
}