Exemplo n.º 1
0
        private void create()
        {
            b2Body bodyB;

            if (connectedB2BodyObject == null)
            {
                bodyB = _world.GetGroundBody();
            }
            else
            {
                bodyB = connectedB2BodyObject.body;
            }

            b2RopeJointDef jointDef = new b2RopeJointDef();
            b2Vec2         anchorA  = _bodyObject.body.GetWorldPoint(localAnchor1);
            b2Vec2         anchorB  = bodyB.GetWorldPoint(localAnchor2);

            anchorA.x = (float)System.Math.Round(anchorA.x, 2);
            anchorA.y = (float)System.Math.Round(anchorA.y, 2);
            anchorB.x = (float)System.Math.Round(anchorB.x, 2);
            anchorB.y = (float)System.Math.Round(anchorB.y, 2);

            jointDef.Initialize(_bodyObject.body, bodyB, anchorA, anchorB, maxLength);
            jointDef.collideConnected = enableCollision;
            _joint     = _world.CreateJoint(jointDef);
            _ropeJoint = _joint as b2RopeJoint;

            _ropeJoint.GetBodyA().SetAwake(true);
            _ropeJoint.GetBodyB().SetAwake(true);
        }
Exemplo n.º 2
0
    internal static b2Joint Create(b2JointDef def)
    {
        b2Joint joint = null;

        switch (def.type)
        {
        case b2JointType.e_distanceJoint:
        {
            joint = new b2DistanceJoint((b2DistanceJointDef)def);
        }
        break;

        case b2JointType.e_mouseJoint:
        {
            joint = new b2MouseJoint((b2MouseJointDef)def);
        }
        break;

        case b2JointType.e_prismaticJoint:
        {
            joint = new b2PrismaticJoint((b2PrismaticJointDef)def);
        }
        break;

        case b2JointType.e_revoluteJoint:
        {
            joint = new b2RevoluteJoint((b2RevoluteJointDef)def);
        }
        break;

        case b2JointType.e_pulleyJoint:
        {
            joint = new b2PulleyJoint((b2PulleyJointDef)def);
        }
        break;

        case b2JointType.e_gearJoint:
        {
            joint = new b2GearJoint((b2GearJointDef)def);
        }
        break;

        case b2JointType.e_wheelJoint:
        {
            joint = new b2WheelJoint((b2WheelJointDef)def);
        }
        break;

        case b2JointType.e_weldJoint:
        {
            joint = new b2WeldJoint((b2WeldJointDef)def);
        }
        break;

        case b2JointType.e_frictionJoint:
        {
            joint = new b2FrictionJoint((b2FrictionJointDef)def);
        }
        break;

        case b2JointType.e_ropeJoint:
        {
            joint = new b2RopeJoint((b2RopeJointDef)def);
        }
        break;

        case b2JointType.e_motorJoint:
        {
            joint = new b2MotorJoint((b2MotorJointDef)def);
        }
        break;

        default:
            Debug.Assert(false);
            break;
        }

        return(joint);
    }
Exemplo n.º 3
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(b2RopeJoint obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }