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


C# PhysicsWorld.AddJoint方法代码示例

本文整理汇总了C#中GameLibrary.Dependencies.Physics.Dynamics.PhysicsWorld.AddJoint方法的典型用法代码示例。如果您正苦于以下问题:C# PhysicsWorld.AddJoint方法的具体用法?C# PhysicsWorld.AddJoint怎么用?C# PhysicsWorld.AddJoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GameLibrary.Dependencies.Physics.Dynamics.PhysicsWorld的用法示例。


在下文中一共展示了PhysicsWorld.AddJoint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AttachBodiesWithRevoluteJoint

        /// <summary>
        /// Attaches the bodies with revolute joints.
        /// </summary>
        /// <param name="world">The world.</param>
        /// <param name="bodies">The bodies.</param>
        /// <param name="localAnchorA">The local anchor A.</param>
        /// <param name="localAnchorB">The local anchor B.</param>
        /// <param name="connectFirstAndLast">if set to <c>true</c> [connect first and last].</param>
        /// <param name="collideConnected">if set to <c>true</c> [collide connected].</param>
        public static List<RevoluteJoint> AttachBodiesWithRevoluteJoint(PhysicsWorld world, List<PhysicsBody> bodies,
                                                                        Vector2 localAnchorA,
                                                                        Vector2 localAnchorB, bool connectFirstAndLast,
                                                                        bool collideConnected)
        {
            List<RevoluteJoint> joints = new List<RevoluteJoint>(bodies.Count + 1);

            for (int i = 1; i < bodies.Count; i++)
            {
                RevoluteJoint joint = new RevoluteJoint(bodies[i], bodies[i - 1], localAnchorA, localAnchorB);
                joint.CollideConnected = collideConnected;
                world.AddJoint(joint);
                joints.Add(joint);
            }

            if (connectFirstAndLast)
            {
                RevoluteJoint lastjoint = new RevoluteJoint(bodies[0], bodies[bodies.Count - 1], localAnchorA,
                                                            localAnchorB);
                lastjoint.CollideConnected = collideConnected;
                world.AddJoint(lastjoint);
                joints.Add(lastjoint);
            }

            return joints;
        }
开发者ID:LostCodeStudios,项目名称:SpaceHordes,代码行数:35,代码来源:PathManager.cs

示例2: CreateDistanceJoint

 public static DistanceJoint CreateDistanceJoint(PhysicsWorld world, PhysicsBody bodyA, PhysicsBody bodyB, Vector2 anchorA,
                                                 Vector2 anchorB)
 {
     DistanceJoint distanceJoint = new DistanceJoint(bodyA, bodyB, anchorA, anchorB);
     world.AddJoint(distanceJoint);
     return distanceJoint;
 }
开发者ID:LostCodeStudios,项目名称:SpaceHordes,代码行数:7,代码来源:JointFactory.cs

示例3: CreateFixedAngleJoint

        /// <summary>
        /// Creates a fixed angle joint.
        /// </summary>
        /// <param name="world">The world.</param>
        /// <param name="body">The body.</param>
        /// <returns></returns>
        public static FixedAngleJoint CreateFixedAngleJoint(PhysicsWorld world, PhysicsBody body)
        {
            FixedAngleJoint angleJoint = new FixedAngleJoint(body);
            world.AddJoint(angleJoint);

            return angleJoint;
        }
开发者ID:LostCodeStudios,项目名称:SpaceHordes,代码行数:13,代码来源:JointFactory.cs

示例4: CreateFixedPrismaticJoint

 public static FixedPrismaticJoint CreateFixedPrismaticJoint(PhysicsWorld world, PhysicsBody body, Vector2 worldAnchor,
                                                             Vector2 axis)
 {
     FixedPrismaticJoint joint = new FixedPrismaticJoint(body, worldAnchor, axis);
     world.AddJoint(joint);
     return joint;
 }
开发者ID:LostCodeStudios,项目名称:SpaceHordes,代码行数:7,代码来源:JointFactory.cs

示例5: CreateFixedDistanceJoint

 public static FixedDistanceJoint CreateFixedDistanceJoint(PhysicsWorld world, PhysicsBody body, Vector2 localAnchor,
                                                           Vector2 worldAnchor)
 {
     FixedDistanceJoint distanceJoint = new FixedDistanceJoint(body, localAnchor, worldAnchor);
     world.AddJoint(distanceJoint);
     return distanceJoint;
 }
开发者ID:LostCodeStudios,项目名称:SpaceHordes,代码行数:7,代码来源:JointFactory.cs

示例6: CreateAngleJoint

        /// <summary>
        /// Creates an angle joint.
        /// </summary>
        /// <param name="world">The world.</param>
        /// <param name="bodyA">The first body.</param>
        /// <param name="bodyB">The second body.</param>
        /// <returns></returns>
        public static AngleJoint CreateAngleJoint(PhysicsWorld world, PhysicsBody bodyA, PhysicsBody bodyB)
        {
            AngleJoint angleJoint = new AngleJoint(bodyA, bodyB);
            world.AddJoint(angleJoint);

            return angleJoint;
        }
开发者ID:LostCodeStudios,项目名称:SpaceHordes,代码行数:14,代码来源:JointFactory.cs

示例7: Deserialize


//.........这里部分代码省略.........
                                break;

                            case JointType.Revolute:
                                joint = new RevoluteJoint();
                                break;

                            case JointType.Weld:
                                joint = new WeldJoint();
                                break;

                            case JointType.Rope:
                                joint = new RopeJoint();
                                break;

                            case JointType.Angle:
                                joint = new AngleJoint();
                                break;

                            case JointType.Slider:
                                joint = new SliderJoint();
                                break;

                            case JointType.Gear:
                                throw new Exception("GearJoint is not supported.");
                            default:
                                throw new Exception("Invalid or unsupported joint.");
                        }

                        joint.CollideConnected = collideConnected;
                        joint.UserData = userData;
                        joint.BodyA = bodyA;
                        joint.BodyB = bodyB;
                        _joints.Add(joint);
                        world.AddJoint(joint);

                        foreach (XMLFragmentElement sn in n.Elements)
                        {
                            // check for specific nodes
                            switch (type)
                            {
                                case JointType.Distance:
                                    {
                                        switch (sn.Name.ToLower())
                                        {
                                            case "dampingratio":
                                                ((DistanceJoint)joint).DampingRatio = float.Parse(sn.Value);
                                                break;

                                            case "frequencyhz":
                                                ((DistanceJoint)joint).Frequency = float.Parse(sn.Value);
                                                break;

                                            case "length":
                                                ((DistanceJoint)joint).Length = float.Parse(sn.Value);
                                                break;

                                            case "localanchora":
                                                ((DistanceJoint)joint).LocalAnchorA = ReadVector(sn);
                                                break;

                                            case "localanchorb":
                                                ((DistanceJoint)joint).LocalAnchorB = ReadVector(sn);
                                                break;
                                        }
                                    }
                                    break;
开发者ID:LostCodeStudios,项目名称:GameLib,代码行数:67,代码来源:Serialization.cs

示例8: CreateGearJoint

 public static GearJoint CreateGearJoint(PhysicsWorld world, PhysicsJoint jointA, PhysicsJoint jointB, float ratio)
 {
     GearJoint gearJoint = new GearJoint(jointA, jointB, ratio);
     world.AddJoint(gearJoint);
     return gearJoint;
 }
开发者ID:LostCodeStudios,项目名称:SpaceHordes,代码行数:6,代码来源:JointFactory.cs

示例9: CreateFrictionJoint

 public static FrictionJoint CreateFrictionJoint(PhysicsWorld world, PhysicsBody bodyA, PhysicsBody bodyB, Vector2 anchorA,
                                                 Vector2 anchorB)
 {
     FrictionJoint frictionJoint = new FrictionJoint(bodyA, bodyB, anchorA, anchorB);
     world.AddJoint(frictionJoint);
     return frictionJoint;
 }
开发者ID:LostCodeStudios,项目名称:SpaceHordes,代码行数:7,代码来源:JointFactory.cs

示例10: CreateFixedRevoluteJoint

 /// <summary>
 /// Creates the fixed revolute joint.
 /// </summary>
 /// <param name="world">The world.</param>
 /// <param name="body">The body.</param>
 /// <param name="bodyAnchor">The body anchor.</param>
 /// <param name="worldAnchor">The world anchor.</param>
 /// <returns></returns>
 public static FixedRevoluteJoint CreateFixedRevoluteJoint(PhysicsWorld world, PhysicsBody body, Vector2 bodyAnchor,
                                                           Vector2 worldAnchor)
 {
     FixedRevoluteJoint fixedRevoluteJoint = new FixedRevoluteJoint(body, bodyAnchor, worldAnchor);
     world.AddJoint(fixedRevoluteJoint);
     return fixedRevoluteJoint;
 }
开发者ID:LostCodeStudios,项目名称:SpaceHordes,代码行数:15,代码来源:JointFactory.cs

示例11: CreateFixedFrictionJoint

 public static FixedFrictionJoint CreateFixedFrictionJoint(PhysicsWorld world, PhysicsBody body, Vector2 bodyAnchor)
 {
     FixedFrictionJoint frictionJoint = new FixedFrictionJoint(body, bodyAnchor);
     world.AddJoint(frictionJoint);
     return frictionJoint;
 }
开发者ID:LostCodeStudios,项目名称:SpaceHordes,代码行数:6,代码来源:JointFactory.cs

示例12: CreatePrismaticJoint

 /// <summary>
 /// Creates a prismatic joint and adds it to the world
 /// </summary>
 /// <param name="world"></param>
 /// <param name="bodyA"></param>
 /// <param name="bodyB"></param>
 /// <param name="localanchorB"></param>
 /// <param name="axis"></param>
 /// <returns></returns>
 public static PrismaticJoint CreatePrismaticJoint(PhysicsWorld world, PhysicsBody bodyA, PhysicsBody bodyB, Vector2 localanchorB,
                                                   Vector2 axis)
 {
     PrismaticJoint joint = CreatePrismaticJoint(bodyA, bodyB, localanchorB, axis);
     world.AddJoint(joint);
     return joint;
 }
开发者ID:LostCodeStudios,项目名称:SpaceHordes,代码行数:16,代码来源:JointFactory.cs

示例13: CreateWeldJoint

 public static WeldJoint CreateWeldJoint(PhysicsWorld world, PhysicsBody bodyA, PhysicsBody bodyB, Vector2 localAnchorA,
                                         Vector2 localAnchorB)
 {
     WeldJoint weldJoint = new WeldJoint(bodyA, bodyB, localAnchorA, localAnchorB);
     world.AddJoint(weldJoint);
     return weldJoint;
 }
开发者ID:LostCodeStudios,项目名称:SpaceHordes,代码行数:7,代码来源:JointFactory.cs

示例14: CreateSliderJoint

 public static SliderJoint CreateSliderJoint(PhysicsWorld world, PhysicsBody bodyA, PhysicsBody bodyB, Vector2 anchorA,
                                             Vector2 anchorB, float minLength, float maxLength)
 {
     SliderJoint sliderJoint = new SliderJoint(bodyA, bodyB, anchorA, anchorB, minLength, maxLength);
     world.AddJoint(sliderJoint);
     return sliderJoint;
 }
开发者ID:LostCodeStudios,项目名称:SpaceHordes,代码行数:7,代码来源:JointFactory.cs

示例15: CreateRevoluteJoint

 /// <summary>
 /// Creates a revolute joint and adds it to the world
 /// </summary>
 /// <param name="world"></param>
 /// <param name="bodyA"></param>
 /// <param name="bodyB"></param>
 /// <param name="anchor"></param>
 /// <returns></returns>
 public static RevoluteJoint CreateRevoluteJoint(PhysicsWorld world, PhysicsBody bodyA, PhysicsBody bodyB, Vector2 anchor)
 {
     RevoluteJoint joint = CreateRevoluteJoint(bodyA, bodyB, anchor);
     world.AddJoint(joint);
     return joint;
 }
开发者ID:LostCodeStudios,项目名称:SpaceHordes,代码行数:14,代码来源:JointFactory.cs


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