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

项目:cgc-game    文件:BodyFactory.java   
private Joint createPrismaticJoint(Body anchor, Body car, Vector2 start) 
{
    PrismaticJointDef pjd = new PrismaticJointDef();

    pjd.bodyA = anchor;
    pjd.bodyB = car;
    pjd.collideConnected = false;
    pjd.enableLimit = true;

    pjd.localAnchorA.set(start);
    pjd.localAnchorB.set(Vector2.Zero);

    pjd.localAxisA.set(-1,0);
    pjd.lowerTranslation = -150;
    pjd.upperTranslation = 150;

    pjd.maxMotorForce = 0;
    pjd.motorSpeed = 0;
    pjd.enableMotor = false;

    return world.createJoint(pjd);
}
项目:tilt-game-android    文件:DebugRenderer.java   
/**
 * Translates b2d Joint to appropriate color, depending on state/type
 * Modify to suit your needs
 * @param joint
 * @return
 */

private static Color jointToColor(Joint joint) {
    switch (joint.getType()) {
    case RevoluteJoint:
    case PrismaticJoint:
    case DistanceJoint:
    case PulleyJoint:
    case MouseJoint:
    case GearJoint:
    case WeldJoint:
    case FrictionJoint:
        return Color.WHITE;

    case Unknown:
    default:
        return Color.WHITE;
    }
}
项目:ZombieCopter    文件:PhysicsScene.java   
public Joint createJoint(JointModel jm){

    String name = uniqueJointName(jm.name);
    logger.debug("Creating Joint from model: " + name + " = " + jm.bodyA + "+" + jm.bodyB);
    Body bodyA = bodies.get(jm.bodyA),
         bodyB = bodies.get(jm.bodyB);

    if (bodyA == null) logger.error("Can't create Joint. Body: " + jm.bodyA + " not found in scene.");
    if (bodyB == null) logger.error("Can't create Joint. Body: " + jm.bodyB + " nof found in scene.");

    Joint joint = jm.toJoint(world,bodyA,bodyB);
    joints.put(name,joint);
    logger.debug("Joint count = " + joints.size);
    if (listener != null) listener.jointAdded(joint);
    return joint;
}
项目:CodeBase    文件:PhysixSystem.java   
public void reset() {
    if (world.isLocked()) {
        throw new GdxRuntimeException("PhysixSystem.reset called in locked state");
    }

    Array<Body> bodies = new Array();
    world.getBodies(bodies);
    for (Body body : bodies) {
        world.destroyBody(body);
    }

    Array<Joint> joints = new Array();
    world.getJoints(joints);
    for (Joint joint : joints) {
        world.destroyJoint(joint);
    }
}
项目:GDX-Logic-Bricks    文件:FlyingDartTest.java   
@Override
public void render() {
    super.render();
    //game.getPhysics().clearForces();

    for (WeldJointDef jointDef : flyingDartCollisionRule.jointDefs) {
        Log.debug(tag, "CreateJoint");
        physics.createJoint(jointDef);

    }
    flyingDartCollisionRule.jointDefs.clear();

    for (Joint joint : flyingDartCollisionRule.destroyJoints) {
        Log.debug(tag, "DestroyJoint");
        physics.destroyJoint(joint);

    }
    flyingDartCollisionRule.destroyJoints.clear();

}
项目:RubeLoader    文件:JointSerializer.java   
@SuppressWarnings("rawtypes")
@Override
public RevoluteJointDef read(Json json, JsonValue jsonData, Class type)
{   
    RevoluteJointDef defaults = RubeDefaults.Joint.revoluteDef;

    RevoluteJointDef def = new RevoluteJointDef();

    Vector2 anchorA = json.readValue("anchorA", Vector2.class, defaults.localAnchorA, jsonData);
    Vector2 anchorB = json.readValue("anchorB", Vector2.class, defaults.localAnchorB, jsonData);

    if(anchorA != null && anchorB != null)
    {
        def.localAnchorA.set(anchorA);
        def.localAnchorB.set(anchorB);
        def.referenceAngle  = json.readValue("refAngle",        float.class, defaults.referenceAngle, jsonData);
        def.enableLimit     = json.readValue("enableLimit",     boolean.class, defaults.enableLimit, jsonData);
        def.lowerAngle      = json.readValue("lowerLimit",      float.class, defaults.lowerAngle, jsonData);
        def.upperAngle      = json.readValue("upperLimit",      float.class, defaults.upperAngle, jsonData);
        def.enableMotor     = json.readValue("enableMotor",     boolean.class, defaults.enableMotor, jsonData);
        def.motorSpeed      = json.readValue("motorSpeed",      float.class, defaults.motorSpeed, jsonData);
        def.maxMotorTorque  = json.readValue("maxMotorTorque",  float.class, defaults.maxMotorTorque, jsonData);
    }

    return def; 
}
项目:RubeLoader    文件:JointSerializer.java   
@SuppressWarnings("rawtypes")
@Override
public DistanceJointDef read(Json json, JsonValue jsonData, Class type)
{   
    DistanceJointDef defaults = RubeDefaults.Joint.distanceDef;

    DistanceJointDef def = new DistanceJointDef();

    Vector2 anchorA = json.readValue("anchorA", Vector2.class, defaults.localAnchorA, jsonData);
    Vector2 anchorB = json.readValue("anchorB", Vector2.class, defaults.localAnchorB, jsonData);

    if(anchorA != null && anchorB != null)
    {
        def.localAnchorA.set(anchorA);
        def.localAnchorB.set(anchorB);
        def.length          = json.readValue("length",          float.class,    defaults.length,        jsonData);
        def.frequencyHz     = json.readValue("frequency",       float.class,    defaults.frequencyHz,   jsonData);
        def.dampingRatio    = json.readValue("dampingRatio",    float.class,    defaults.dampingRatio,  jsonData);
    }

    return def; 
}
项目:RubeLoader    文件:JointSerializer.java   
@SuppressWarnings("rawtypes")
@Override
public MouseJointDef read(Json json, JsonValue jsonData, Class type)
{   
    MouseJointDef defaults = RubeDefaults.Joint.mouseDef;

    MouseJointDef def = new MouseJointDef();

    // Don't forget to set the target to the joint once it's created
    target = json.readValue("target", Vector2.class, defaults.target, jsonData);

    Vector2 anchorB = json.readValue("anchorB", Vector2.class, defaults.target, jsonData);

    if(target != null && anchorB != null)
    {
        def.target.set(anchorB);
        def.maxForce        = json.readValue("maxForce",        float.class,    defaults.maxForce,      jsonData);
        def.frequencyHz     = json.readValue("frequency",       float.class,    defaults.frequencyHz,   jsonData);
        def.dampingRatio    = json.readValue("dampingRatio",    float.class,    defaults.dampingRatio,  jsonData);
    }

    return def; 
}
项目:RubeLoader    文件:JointSerializer.java   
@SuppressWarnings("rawtypes")
@Override
public WeldJointDef read(Json json, JsonValue jsonData, Class type)
{   
    WeldJointDef defaults = RubeDefaults.Joint.weldDef;

    WeldJointDef def = new WeldJointDef();

    Vector2 anchorA = json.readValue("anchorA", Vector2.class, defaults.localAnchorA, jsonData);
    Vector2 anchorB = json.readValue("anchorB", Vector2.class, defaults.localAnchorB, jsonData);

    if(anchorA != null && anchorB != null)
    {
        def.localAnchorA.set(anchorA);
        def.localAnchorB.set(anchorB);
        def.referenceAngle  = json.readValue("refAngle", float.class, defaults.referenceAngle, jsonData);
    }

    return def; 
}
项目:RubeLoader    文件:JointSerializer.java   
@SuppressWarnings("rawtypes")
@Override
public FrictionJointDef read(Json json, JsonValue jsonData, Class type)
{   
    FrictionJointDef defaults = RubeDefaults.Joint.frictionDef;

    FrictionJointDef def = new FrictionJointDef();

    Vector2 anchorA = json.readValue("anchorA", Vector2.class, defaults.localAnchorA, jsonData);
    Vector2 anchorB = json.readValue("anchorB", Vector2.class, defaults.localAnchorB, jsonData);

    if(anchorA != null && anchorB != null)
    {
        def.localAnchorA.set(anchorA);
        def.localAnchorB.set(anchorB);
        def.maxForce    = json.readValue("maxForce", float.class, defaults.maxForce, jsonData);
        def.maxTorque   = json.readValue("maxTorque", float.class, defaults.maxTorque, jsonData);
    }

    return def; 
}
项目:RubeLoader    文件:JointSerializer.java   
@SuppressWarnings("rawtypes")
@Override
public RopeJointDef read(Json json, JsonValue jsonData, Class type)
{   
    RopeJointDef defaults = RubeDefaults.Joint.ropeDef;

    RopeJointDef def = new RopeJointDef();

    Vector2 anchorA     = json.readValue("anchorA", Vector2.class, defaults.localAnchorA, jsonData);
    Vector2 anchorB     = json.readValue("anchorB", Vector2.class, defaults.localAnchorB, jsonData);

    if(anchorA != null && anchorB != null)
    {
        def.localAnchorA.set(anchorA);
        def.localAnchorB.set(anchorB);
        def.maxLength   = json.readValue("maxLength",       float.class,    defaults.maxLength,         jsonData);
    }

    return def; 
}
项目:flixel-gdx-box2d    文件:B2FlxB.java   
/**
 * Called by <code>B2FlxState</code> to setup the vertices.
 */
public static void init()
{   
    // Construct a world object.
    if(world == null)
        world = new World(_gravity, true);

    // Create the contact manager.      
    contact = new B2FlxContactManager(B2FlxB.world);

    if(FlxG.debug)
        B2FlxB.initDebugger();

    controllers = new Array<B2Controller>();
    scheduledForRemoval = new Array<FlxBasic>();
    scheduledForRevival = new Array<FlxBasic>();
    scheduledForInActive = new Array<B2FlxShape>();
    scheduledForActive = new Array<B2FlxShape>();
    scheduledForMove = new Array<B2FlxShape>();
    flxJoints = new Array<B2FlxJoint>();
    bodies = new Array<Body>();
    joints = new Array<Joint>();
}
项目:NationSoccer    文件:DebugRenderer.java   
/**
 * Translates b2d Joint to appropriate color, depending on state/type
 * Modify to suit your needs
 * @param joint
 * @return
 */

private static Color jointToColor(Joint joint) {
    switch (joint.getType()) {
    case RevoluteJoint:
    case PrismaticJoint:
    case DistanceJoint:
    case PulleyJoint:
    case MouseJoint:
    case GearJoint:
    case WeldJoint:
    case FrictionJoint:
        return Color.WHITE;

    case Unknown:
    default:
        return Color.WHITE;
    }
}
项目:cgc-game    文件:BodyFactory.java   
public Joint createRopeJoint(Body b1, Body b2, float maxLength)
{
    RopeJointDef rjd = new RopeJointDef();
    rjd.bodyA = b1;
    rjd.bodyB = b2;
    rjd.collideConnected = true;
    rjd.localAnchorA.set(Vector2.Zero);
    rjd.localAnchorB.set(Vector2.Zero);
    rjd.maxLength = maxLength;
    return world.createJoint(rjd);
}
项目:cgc-game    文件:BodyFactory.java   
public Joint createWeldJoint(Body b1, Body b2, Vector2 anchor)
{
    WeldJointDef wjd = new WeldJointDef();

    wjd.bodyA = b1;
    wjd.bodyB = b2;
    wjd.collideConnected = false;
    wjd.localAnchorA.set(Vector2.Zero);
    wjd.localAnchorB.set(anchor);
    wjd.referenceAngle = 0.0f;

    return world.createJoint(wjd);
}
项目:cgc-game    文件:Patcher.java   
public void leftRightCenter(Player left, Player right, Joint center)
{
    left.setRightPlayer(right);
    left.setRightJoint(center);
    right.setLeftPlayer(left);
    right.setLeftJoint(center);
}
项目:tilt-game-android    文件:RenderOfJointPolyline.java   
public RenderOfJointPolyline(Joint joint, VertexBufferObjectManager pVBO, float pMarkerSize) {
    super(joint);
    mMarkerSize = pMarkerSize;

    mXPoints = new float[4];
    mYPoints = new float[4];

    mEntity = new PolyLine(0, 0, mXPoints, mYPoints, pVBO);
    mEntity.setColor(1, 1, 1);  // just to overcome some polyline issues
}
项目:ZombieCopter    文件:PhysicsScene.java   
public String addJoint(String name, Joint j){
    logger.debug("Joint added: " + name);

    joints.put(name,j);
    if (listener != null) listener.jointAdded(j);
    return name;
}
项目:ZombieCopter    文件:PhysicsScene.java   
public void destroy(){
    logger.debug(String.format("Destroying: %d fixtures, %d bodies, & %d joints...",
                                fixtures.size,bodies.size,joints.size));

    for (Joint j : joints.values()){
        world.destroyJoint(j);
        if (listener != null) listener.jointRemoved(j);
        logger.debug("Joint Destroyed");
    }

    for (Body b : bodies.values()){
        for (Fixture f : b.getFixtureList()){
            b.destroyFixture(f);
            if (listener != null) listener.fixtureRemoved(f);
            logger.debug("Fixture Destroyed");
        }
        world.destroyBody(b);
        if (listener != null) listener.bodyRemoved(b);
        logger.debug("Body Destroyed");
    }


    fixtures.clear();
    bodies.clear();
    joints.clear();
    uniqueId = 0;
    primaryBody = null;
    logger.debug("---Destroyed");
}
项目:ZombieCopter    文件:PhysicsScene.java   
public void destroyJoint(String name){
    logger.debug("Destroy Joint: " + name);
    Joint j = joints.get(name); 
    if (j != null){
        world.destroyJoint(j);
        joints.remove(name);
        if (listener != null) listener.jointRemoved(j);
    }
    else logger.debug("Could not destroy joint: " + name + " not found");
}
项目:ZombieCopter    文件:PhysicsScene.java   
public PhysicsSceneModel toSceneModel(){
    logger.debug("Creating Scene Model");
    PhysicsSceneModel physicsModel = new PhysicsSceneModel();       

    //Bodies
    for (ObjectMap.Entry<String,Body> bodyEntry : bodies.entries()){
        BodyModel bodyModel = new BodyModel(bodyEntry.key,bodyEntry.value);
        //clear un-named fixtures. We'll manually add them with names included
        bodyModel.fixtures.clear();

        //Fixtures
        for (ObjectMap.Entry<String,Fixture> fixtureEntry : fixtures.entries()){
            if (fixtureEntry.value.getBody() == bodyEntry.value){
                FixtureModel fixModel = new FixtureModel(fixtureEntry.key,fixtureEntry.value);
                bodyModel.fixtures.add(fixModel);
            }
        }
        physicsModel.bodyModels.add(bodyModel);
    }

    //Joints
    for (ObjectMap.Entry<String,Joint> jointEntry : joints.entries()){
        Joint j = jointEntry.value;
        JointModel jointModel = new JointModel(jointEntry.key,jointEntry.value,getName(j.getBodyA()), getName(j.getBodyB()));
        physicsModel.jointModels.add(jointModel);
    }
    return physicsModel;
}
项目:jumplings    文件:MainActor.java   
/**
 * Explosi�n del actor
 */
public void desintegrateInDebris() {
    // se rompen las joints
    if (mJoints != null) {
        Object[] aux = mJoints.toArray();
        for (int i = 0; i < aux.length; i++) {
            getWorld().destroyJoint(this, (Joint) aux[i]);
        }
    }

    // se aceleran para que salgan disparados
    applyBlast(getDebrisBodies(), DESINTEGRATION_FORCE);
}
项目:Blob-Game    文件:SwingingCan.java   
@Override
public Object observe() {
    // Sweet Lord...  This is gona be expensive...
    ArrayList<Blob> blobs = Game.get().getLevel().getBlobs(true);
    for (Blob blob : blobs){
        ArrayList<Joint> joints = blob.getJoints();
        for (Joint joint : joints){
            if (joint.getBodyA().getUserData().equals(this) || joint.getBodyB().getUserData().equals(this)){
                return true;
            };
        }
    }
    return false;
}
项目:Blob-Game    文件:Blob.java   
/**
 * Constructor. No non-optional parameters may be added to this constructor.
 * This should contain only properties, and code that MUST run before later
 * init,
 * 
 * @param level
 *            The level that contains this actor
 * @param id
 *            The id
 */
public Blob(Level level, long id) {
    super(level, id);
    mName = "Blob";
    mParticles = new ArrayList<Body>();
    mSprings = new ArrayList<Spring>();
    mJoints = new ArrayList<Joint>();
    mVCenter = new Vector2(0, 0);
    mOldVCenter = new Vector2();
    mLeftEyeDest = new Vector2(0, 0);
    mRightEyeDest = new Vector2(0, 0);

    mPoof = 1;

    if (getLevel().getAssetKey() != null) {
        Color squishColor = new Color(0f, .9f, 0f, 1f);
        Color solidColor = new Color(squishColor);
        solidColor.mul(.7f, .7f, .7f, 1f);
        mBlobDrawable = new BlobDrawable(squishColor, solidColor);
        ((CompositeDrawable) mDrawable).mDrawables.add(mBlobDrawable);
    }
    makeBlobBody();
    if (LevelView.mUseLights) {
        mLight = new PointLight(Game.get().getLevelView().getRayHandler(), 256, new Color(0f,
                0f, 0f, 1f), 7, -10000, -10000);
        mLight.setSoft(true);
        mLight.setSoftnessLenght(.5f);
        mLight.setActive(false);
        mLight.attachToBody(mLeftEye, 0f, 0f);
    }
    mSoundTimer = new Timer();
    mSoundTimer.setTimer(12);
    mSoundTimer.unpause();
    setProp("Player ID", (Integer) 0);
}
项目:Blob-Game    文件:Blob.java   
private void breakStrainedJoints() {

        for (Iterator<Joint> iter = mJoints.iterator(); iter.hasNext();) {
            Joint j = iter.next();

            // Ignore joint if it isn't breaking
            Vector2 force = j.getReactionForce(60);
            if (force.len() < GRAB_BREAK_FORCE) {
                continue;
            }

            // Remove joint
            if (!mStrain) {
                Actor otherActor;
                Body body;
                body = (j.getBodyA().equals(mBody) ? j.getBodyB() : j.getBodyA());
                if (j.getBodyA() != null && j.getBodyB() != null) {
                    otherActor = (Actor) body.getUserData();
                    if (otherActor instanceof Blob) {
                        ((Blob) otherActor).removeJoint(j);
                    }
                    if (otherActor instanceof BattleBall) {
                        ((BattleBall) otherActor).setProp("Grabbers", (Integer) (Convert
                                .getInt(((BattleBall) otherActor).getProp("Grabbers")) - 1));
                    }
                    getLevel().getWorld().destroyJoint(j);
                    Game.get().playTickSound();
                    iter.remove();
                }
            }
            mStrain = false;

        }
    }
项目:RubeLoader    文件:WorldSerializer.java   
public WorldSerializer(RubeScene scene, Json _json)
{
    this.scene = scene;

    bodySerializer = new BodySerializer(scene,_json);
    _json.setSerializer(Body.class, bodySerializer);

    jointSerializer = new JointSerializer(scene,_json);
    _json.setSerializer(Joint.class, jointSerializer);

    imageSerializer = new ImageSerializer(scene);
    _json.setSerializer(RubeImage.class, imageSerializer);
}
项目:RubeLoader    文件:JointSerializer.java   
@SuppressWarnings("rawtypes")
@Override
public PrismaticJointDef read(Json json, JsonValue jsonData, Class type)
{   
    PrismaticJointDef defaults = RubeDefaults.Joint.prismaticDef;

    PrismaticJointDef def = new PrismaticJointDef();

    Vector2 anchorA = json.readValue("anchorA", Vector2.class, defaults.localAnchorA, jsonData);
    Vector2 anchorB = json.readValue("anchorB", Vector2.class, defaults.localAnchorB, jsonData);

    if(anchorA != null && anchorB != null)
    {
        def.localAnchorA.set(anchorA);
        def.localAnchorB.set(anchorB);

        Vector2 localAxis = json.readValue("localAxisA", Vector2.class, defaults.localAxisA, jsonData);
        if(localAxis == null)
            localAxis = json.readValue("localAxis1", Vector2.class, defaults.localAxisA, jsonData);
        if(localAxis!=null)
            def.localAxisA.set(localAxis);

        def.referenceAngle      = json.readValue("refAngle",        float.class,    defaults.referenceAngle,    jsonData);
        def.enableLimit         = json.readValue("enableLimit",     boolean.class,  defaults.enableLimit,       jsonData);
        def.lowerTranslation    = json.readValue("lowerLimit",      float.class,    defaults.lowerTranslation,  jsonData);
        def.upperTranslation    = json.readValue("upperLimit",      float.class,    defaults.upperTranslation,  jsonData);
        def.enableMotor         = json.readValue("enableMotor",     boolean.class,  defaults.enableMotor,       jsonData);
        def.motorSpeed          = json.readValue("motorSpeed",      float.class,    defaults.motorSpeed,        jsonData);
        def.maxMotorForce       = json.readValue("maxMotorForce",   float.class,    defaults.maxMotorForce,     jsonData);
    }

    return def; 
}
项目:RubeLoader    文件:JointSerializer.java   
@SuppressWarnings("rawtypes")
@Override
public PulleyJointDef read(Json json, JsonValue jsonData, Class type)
{   
    PulleyJointDef defaults = RubeDefaults.Joint.pulleyDef;

    PulleyJointDef def = new PulleyJointDef();

    Vector2 anchorA = json.readValue("anchorA", Vector2.class, defaults.localAnchorA, jsonData);
    Vector2 anchorB = json.readValue("anchorB", Vector2.class, defaults.localAnchorB, jsonData);

    Vector2 groundAnchorA = json.readValue("groundAnchorA", Vector2.class, defaults.groundAnchorA, jsonData);
    Vector2 groundAnchorB = json.readValue("groundAnchorB", Vector2.class, defaults.groundAnchorB, jsonData);

    if(anchorA != null && anchorB != null && groundAnchorA != null && groundAnchorB !=null)
    {
        def.localAnchorA.set(anchorA);
        def.localAnchorB.set(anchorB);
        defaults.groundAnchorA.set(groundAnchorA);
        defaults.groundAnchorB.set(groundAnchorB);

        def.lengthA     = json.readValue("lengthA", float.class,    defaults.lengthA,   jsonData);
        def.lengthB     = json.readValue("lengthB", float.class,    defaults.lengthB,   jsonData);
        def.ratio       = json.readValue("ratio",   float.class,    defaults.ratio,     jsonData);
    }

    return def; 
}
项目:RubeLoader    文件:JointSerializer.java   
@SuppressWarnings("rawtypes")
@Override
public WheelJointDef read(Json json, JsonValue jsonData, Class type)
{   
    WheelJointDef defaults = RubeDefaults.Joint.wheelDef;

    WheelJointDef def = new WheelJointDef();

    Vector2 anchorA     = json.readValue("anchorA", Vector2.class, defaults.localAnchorA, jsonData);
    Vector2 anchorB     = json.readValue("anchorB", Vector2.class, defaults.localAnchorB, jsonData);
    Vector2 localAxisA  = json.readValue("localAxisA", Vector2.class, defaults.localAxisA, jsonData);

    if(anchorA != null && anchorB != null)
    {
        def.localAnchorA.set(anchorA);
        def.localAnchorB.set(anchorB);
        def.localAxisA.set(localAxisA);

        def.enableMotor         = json.readValue("enableMotor",         boolean.class,  defaults.enableMotor,       jsonData);
        def.motorSpeed          = json.readValue("motorSpeed",          float.class,    defaults.motorSpeed,        jsonData);
        def.maxMotorTorque      = json.readValue("maxMotorTorque",      float.class,    defaults.maxMotorTorque,    jsonData);
        def.frequencyHz         = json.readValue("springFrequency",     float.class,    defaults.frequencyHz,       jsonData);
        def.dampingRatio        = json.readValue("springDampingRatio",  float.class,    defaults.dampingRatio,      jsonData);
    }

    return def; 
}
项目:flixel-gdx-box2d    文件:B2FlxGearJoint.java   
/**
 * Set the first joint. It must be either a revolute or prismatic joint.
 * @param joint1    The joint that will be connected to this joint.
 * @return  This joint. Handy for chaining stuff together.
 */
public B2FlxGearJoint setJoint1(Joint joint1)
{
    if(!FlxU.getClassName(joint1, false).equals("com.badlogic.gdx.physics.box2d.joints.RevoluteJoint") 
    && !FlxU.getClassName(joint1, false).equals("com.badlogic.gdx.physics.box2d.joints.PrismaticJoint"))
        throw new Error("The joint must be either a revolute or prismatic joint!");
    ((GearJointDef)jointDef).joint1 = joint1;
    return this;
}
项目:flixel-gdx-box2d    文件:B2FlxGearJoint.java   
/**
 * Set the second joint. It must be either a revolute or prismatic joint.
 * @param joint2    The joint that will be connected to this joint.
 * @return  This joint. Handy for chaining stuff together.
 */
public B2FlxGearJoint setJoint2(Joint joint2)
{
    if(!FlxU.getClassName(joint2, false).equals("com.badlogic.gdx.physics.box2d.joints.RevoluteJoint") 
    && !FlxU.getClassName(joint2, false).equals("com.badlogic.gdx.physics.box2d.joints.PrismaticJoint"))
        throw new Error("The joint must be either a revolute or prismatic joint!");
    ((GearJointDef)jointDef).joint2 = joint2;
    return this;
}
项目:NationSoccer    文件:RenderOfJointPolyline.java   
public RenderOfJointPolyline(Joint joint, VertexBufferObjectManager pVBO, float pMarkerSize) {
    super(joint);
    mMarkerSize = pMarkerSize;

    mXPoints = new float[4];
    mYPoints = new float[4];

    mEntity = new PolyLine(0, 0, mXPoints, mYPoints, pVBO);
    mEntity.setColor(1, 1, 1);  // just to overcome some polyline issues
}
项目:cgc-game    文件:Player.java   
public Joint getLeftJoint()
{
    return leftJoint;
}
项目:cgc-game    文件:Player.java   
public void setLeftJoint(Joint newLeft)
{
    leftJoint = newLeft;
}
项目:cgc-game    文件:Player.java   
public Joint getRightJoint()
{
    return rightJoint;
}
项目:cgc-game    文件:Player.java   
public void setRightJoint(Joint newRight)
{
    rightJoint = newRight;
}
项目:cgc-game    文件:BossFight.java   
private void chainTogether(Player p1, Player p2, int numChainLinks)
{
    Array<Body> bodyList = new Array<Body>();
    Body b;
    GameEntity ge;

    for (int j = 0; j < numChainLinks; j++)
    {
        b = bf.createRectangle(p1.getBody().getPosition().x+0.3f+0.2f*j, p1.getBody().getPosition().y, 
                                0.2f, 0.1f, BodyType.DynamicBody, BodyFactory.CAT_CHAIN, 
                                BodyFactory.MASK_CHAIN, CGCWorld.chainDensity);
        bodyList.add(b);
        if (j%2 == 1)
        {
            ge = new ChainLink(com.percipient24.cgc.art.TextureAnimationDrawer.chainAnims[0], null, null, EntityType.CHAINLINK, b);
        }
        else
        {
            ge = new ChainLink(com.percipient24.cgc.art.TextureAnimationDrawer.chainAnims[1], null, null, EntityType.CHAINLINK, b);
        }
        b.setUserData(ge);
        b.setAngularDamping(1000.0f);
    }

    for (int j = 0; j < numChainLinks; j+=2)
    {
        ((ChainLink) (bodyList.get(j).getUserData())).addToWorldLayers(lh);

        if (j == numChainLinks-1)
        {
            j = -1;
        }
    }

    for (int j = 0; j < numChainLinks+1; j++)
    {
        if (j == 0)
        {
            bf.createRevoluteJoint(p1.getBody(), bodyList.get(j),
                                    new Vector2(0.0f,0f), new Vector2(-0.4f,0f));
        }
        else if (j == numChainLinks)
        {
            bf.createRevoluteJoint(bodyList.get(j-1), p2.getBody(),
                                    new Vector2(0.4f,0f), new Vector2(0.0f,0f));
        }
        else
        {
            bf.createRevoluteJoint(bodyList.get(j-1), bodyList.get(j),
                                    new Vector2(0.1f,0f), new Vector2(-0.1f,0f));
        }
    }

    Joint middle = bf.createRopeJoint(p1.getBody(), p2.getBody(), 0.27f*numChainLinks);

    Player left = p1;
    Player right = p2;

    CGCWorld.patcher.leftRightCenter(left, right, middle);

    for (int j = 0; j < numChainLinks; j++)
    {
        CGCWorld.patcher.setupChain(bodyList.get(j), left);
    }
}
项目:KillTheNerd    文件:BodyFactory.java   
public static Joint createJoint(final Body bodyA, final Body bodyB) {
    final RevoluteJointDef joint = new RevoluteJointDef();
    joint.bodyA = bodyA;
    joint.bodyB = bodyB;
    return BodyFactory.world.createJoint(joint);
}
项目:tilt-game-android    文件:PhysicsWorld.java   
public Joint createJoint(final JointDef pDef) {
    return this.mWorld.createJoint(pDef);
}
项目:tilt-game-android    文件:PhysicsWorld.java   
public void destroyJoint(final Joint pJoint) {
    this.mWorld.destroyJoint(pJoint);
}