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


C# b2World.SetSubStepping方法代码示例

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


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

示例1: N2b2World

        public b2World N2b2World(JObject worldValue)
        {
            b2World world = new b2World(jsonToVec("gravity", worldValue));

            world.SetAllowSleeping((bool)worldValue.GetValue("allowSleep"));
            world.ClearForces();
            //world.Set(worldValue.getBoolean("autoClearForces"));
            world.SetWarmStarting((bool)worldValue.GetValue("warmStarting"));
            world.SetContinuousPhysics((bool)worldValue.GetValue("continuousPhysics"));
            world.SetSubStepping((bool)worldValue.GetValue("subStepping"));

            readCustomPropertiesFromJson(world, worldValue);

            int i = 0;
            JArray bodyValues = (JArray)worldValue["body"];
            if (null != bodyValues)
            {
                int numBodyValues = bodyValues.Count;
                for (i = 0; i < numBodyValues; i++)
                {
                    JObject bodyValue = (JObject)bodyValues[i];
                    b2Body body = N2b2Body(world, bodyValue);
                    readCustomPropertiesFromJson(body, bodyValue);
                    m_bodies.Add(body);
                    m_indexToBodyMap.Add(i, body);
                }
            }

            // need two passes for joints because gear joints reference other joints
            JArray jointValues = (JArray)worldValue["joint"];
            if (null != jointValues)
            {
                int numJointValues = jointValues.Count;
                for (i = 0; i < numJointValues; i++)
                {
                    JObject jointValue = (JObject)jointValues[i];
                    if (jointValue["type"].ToString() != "gear")
                    {
                        b2Joint joint = j2b2Joint(world, jointValue);
                        readCustomPropertiesFromJson(joint, jointValue);
                        m_joints.Add(joint);
                    }
                }
                for (i = 0; i < numJointValues; i++)
                {
                    JObject jointValue = (JObject)jointValues[i];
                    if (jointValue["type"].ToString() == "gear")
                    {
                        b2Joint joint = j2b2Joint(world, jointValue);
                        readCustomPropertiesFromJson(joint, jointValue);
                        m_joints.Add(joint);
                    }
                }
            }
            i = 0;
            JArray imageValues = (JArray)worldValue["image"];
            if (null != imageValues)
            {
                int numImageValues = imageValues.Count;
                for (i = 0; i < numImageValues; i++)
                {
                    JObject imageValue = (JObject)imageValues[i];
                    Nb2dJsonImage image = j2b2dJsonImage(imageValue);
                    readCustomPropertiesFromJson(image, imageValue);
                    m_images.Add(image);
                }
            }
            return world;
        }
开发者ID:netonjm,项目名称:RubeLoader,代码行数:69,代码来源:Nb2dJson.cs

示例2: SetupWorld

        static void SetupWorld(bool setupGround)
        {
            var gravity = new b2Vec2(0.0f, -10.0f);
            _world = new b2World(gravity);
            _world.SetAllowSleeping(true);
            _world.SetContinuousPhysics(true);
            _world.SetSubStepping(true);
            _world.SetWarmStarting(true);
            _world.SetDestructionListener(new Destructo());
            _world.SetContactListener(new Contacto());
            if (!setupGround)
            {
                return;
            }
            // Call the body factory which allocates memory for the ground body
            // from a pool and creates the ground box shape (also from a pool).
            // The body is also added to the world.
            b2BodyDef def = b2BodyDef.Create();
            def.allowSleep = true;
            def.position = b2Vec2.Zero;
            def.type = b2BodyType.b2_staticBody;
            b2Body groundBody = _world.CreateBody(def);
            groundBody.SetActive(true);

            // bottom
            b2EdgeShape groundBox = new b2EdgeShape();
            groundBox.Set(b2Vec2.Zero, new b2Vec2(width, 0));
            b2FixtureDef fd = b2FixtureDef.Create();
            fd.shape = groundBox;
            groundBody.CreateFixture(fd);

            // top
            groundBox = new b2EdgeShape();
            groundBox.Set(new b2Vec2(0, height), new b2Vec2(width, height));
            fd.shape = groundBox;
            groundBody.CreateFixture(fd);

            // left
            groundBox = new b2EdgeShape();
            groundBox.Set(new b2Vec2(0, height), b2Vec2.Zero);
            fd.shape = groundBox;
            groundBody.CreateFixture(fd);

            // right
            groundBox = new b2EdgeShape();
            groundBox.Set(new b2Vec2(width, height), new b2Vec2(width, 0));
            fd.shape = groundBox;
            groundBody.CreateFixture(fd);

            _world.Dump();
        }
开发者ID:Cocos2DXNA,项目名称:CocosPhysics,代码行数:51,代码来源:Program.cs


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