当前位置: 首页>>代码示例>>Java>>正文


Java WeldJoint类代码示例

本文整理汇总了Java中com.badlogic.gdx.physics.box2d.joints.WeldJoint的典型用法代码示例。如果您正苦于以下问题:Java WeldJoint类的具体用法?Java WeldJoint怎么用?Java WeldJoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


WeldJoint类属于com.badlogic.gdx.physics.box2d.joints包,在下文中一共展示了WeldJoint类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setWeldJoint

import com.badlogic.gdx.physics.box2d.joints.WeldJoint; //导入依赖的package包/类
/**
 * Create a weld joint between this actor and some other actor, to force the actors to stick
 * together.
 *
 * @param other  The actor that will be fused to this actor
 * @param otherX The X coordinate (relative to center) where joint fuses to the other actor
 * @param otherY The Y coordinate (relative to center) where joint fuses to the other actor
 * @param localX The X coordinate (relative to center) where joint fuses to this actor
 * @param localY The Y coordinate (relative to center) where joint fuses to this actor
 * @param angle  The angle between the actors
 */
public void setWeldJoint(WorldActor other, float otherX, float otherY, float localX,
                         float localY, float angle) {
    WeldJointDef w = new WeldJointDef();
    w.bodyA = mBody;
    w.bodyB = other.mBody;
    w.localAnchorA.set(localX, localY);
    w.localAnchorB.set(otherX, otherY);
    w.referenceAngle = angle;
    w.collideConnected = false;
    mExplicitWeldJoint = (WeldJoint) mScene.mWorld.createJoint(w);
}
 
开发者ID:mfs409,项目名称:liblol,代码行数:23,代码来源:WorldActor.java

示例2: handleSticky

import com.badlogic.gdx.physics.box2d.joints.WeldJoint; //导入依赖的package包/类
/**
 * When a hero collides with a "sticky" obstacle, this figures out what to do
 *
 * @param sticky  The sticky actor... it should always be an obstacle for now
 * @param other   The other actor... it should always be a hero for now
 * @param contact A description of the contact event
 */
private void handleSticky(final WorldActor sticky, final WorldActor other, Contact contact) {
    // don't create a joint if we've already got one
    if (other.mDJoint != null)
        return;
    // don't create a joint if we're supposed to wait
    if (System.currentTimeMillis() < other.mStickyDelay)
        return;
    // go sticky obstacles... only do something if we're hitting the
    // obstacle from the correct direction
    if ((sticky.mIsSticky[0] && other.getYPosition() >= sticky.getYPosition() + sticky.mSize.y)
            || (sticky.mIsSticky[1] && other.getXPosition() + other.mSize.x <= sticky.getXPosition())
            || (sticky.mIsSticky[3] && other.getXPosition() >= sticky.getXPosition() + sticky.mSize.x)
            || (sticky.mIsSticky[2] && other.getYPosition() + other.mSize.y <= sticky.getYPosition())) {
        // create distance and weld joints... somehow, the combination is needed to get this to
        // work. Note that this function runs during the box2d step, so we need to make the
        // joint in a callback that runs later
        final Vector2 v = contact.getWorldManifold().getPoints()[0];
        mOneTimeEvents.add(new LolAction() {
            @Override
            public void go() {
                other.mBody.setLinearVelocity(0, 0);
                DistanceJointDef d = new DistanceJointDef();
                d.initialize(sticky.mBody, other.mBody, v, v);
                d.collideConnected = true;
                other.mDJoint = (DistanceJoint) mWorld.createJoint(d);
                WeldJointDef w = new WeldJointDef();
                w.initialize(sticky.mBody, other.mBody, v);
                w.collideConnected = true;
                other.mWJoint = (WeldJoint) mWorld.createJoint(w);
            }
        });
    }
}
 
开发者ID:mfs409,项目名称:liblol,代码行数:41,代码来源:MainScene.java

示例3: getJoint

import com.badlogic.gdx.physics.box2d.joints.WeldJoint; //导入依赖的package包/类
@Override
public WeldJoint getJoint(){return (WeldJoint)joint;}
 
开发者ID:flixel-gdx,项目名称:flixel-gdx-box2d,代码行数:3,代码来源:B2FlxWeldJoint.java

示例4: createProperJoint

import com.badlogic.gdx.physics.box2d.joints.WeldJoint; //导入依赖的package包/类
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;
}
 
开发者ID:isnuryusuf,项目名称:ingress-indonesia-dev,代码行数:55,代码来源:World.java


注:本文中的com.badlogic.gdx.physics.box2d.joints.WeldJoint类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。