• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Shapes.b2EdgeShape类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Box2D.Collision.Shapes.b2EdgeShape的典型用法代码示例。如果您正苦于以下问题:C# b2EdgeShape类的具体用法?C# b2EdgeShape怎么用?C# b2EdgeShape使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



b2EdgeShape类属于Box2D.Collision.Shapes命名空间,在下文中一共展示了b2EdgeShape类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: VaryingRestitution

        public VaryingRestitution()
        {
            {
                b2BodyDef bd  = new b2BodyDef();
                b2Body ground = m_world.CreateBody(bd);

                b2EdgeShape shape = new b2EdgeShape();
                shape.Set(new b2Vec2(-40.0f, 0.0f), new b2Vec2(40.0f, 0.0f));
                ground.CreateFixture(shape, 0.0f);
            }

            {
                b2CircleShape shape = new b2CircleShape();
                shape.Radius = 1.0f;

                b2FixtureDef fd = new b2FixtureDef();
                fd.shape = shape;
                fd.density = 1.0f;

                float[] restitution = {0.0f, 0.1f, 0.3f, 0.5f, 0.75f, 0.9f, 1.0f};

                for (int i = 0; i < 7; ++i)
                {
                    b2BodyDef bd  = new b2BodyDef();
                    bd.type = b2BodyType.b2_dynamicBody;
                    bd.position.Set(-10.0f + 3.0f * i, 20.0f);

                    b2Body body = m_world.CreateBody(bd);

                    fd.restitution = restitution[i];
                    body.CreateFixture(fd);
                }
            }
        }
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:34,代码来源:VaryingRestitution.cs


示例2: Breakable

        public Breakable()
        {
            // Ground body
            {
                b2BodyDef bd  = new b2BodyDef();
                b2Body ground = m_world.CreateBody(bd);

                b2EdgeShape shape = new b2EdgeShape();
                shape.Set(new b2Vec2(-40.0f, 0.0f), new b2Vec2(40.0f, 0.0f));
                ground.CreateFixture(shape, 0.0f);
            }

            // Breakable dynamic body
            {
                b2BodyDef bd  = new b2BodyDef();
                bd.type = b2BodyType.b2_dynamicBody;
                bd.position = new b2Vec2(0.0f, 40.0f);
                bd.angle = 0.25f * b2Settings.b2_pi;
                m_body1 = m_world.CreateBody(bd);

                m_shape1.SetAsBox(0.5f, 0.5f, new b2Vec2(-0.5f, 0.0f), 0.0f);
                m_piece1 = m_body1.CreateFixture(m_shape1, 1.0f);

                m_shape2.SetAsBox(0.5f, 0.5f, new b2Vec2(0.5f, 0.0f), 0.0f);
                m_piece2 = m_body1.CreateFixture(m_shape2, 1.0f);
            }

            m_break = false;
            m_broke = false;
        }
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:30,代码来源:Breakable.cs


示例3: SphereStack

        public SphereStack()
        {
            {
                b2BodyDef bd  = new b2BodyDef();
                b2Body ground = m_world.CreateBody(bd);

                b2EdgeShape shape = new b2EdgeShape();
                shape.Set(new b2Vec2(-40.0f, 0.0f), new b2Vec2(40.0f, 0.0f));
                ground.CreateFixture(shape, 0.0f);
            }

            {
                b2CircleShape shape = new b2CircleShape();
                shape.Radius = 1.0f;

                for (int i = 0; i < e_count; ++i)
                {
                    b2BodyDef bd  = new b2BodyDef();
                    bd.type = b2BodyType.b2_dynamicBody;
                    bd.position.Set(0.0f, 4.0f + 3.0f * i);

                    m_bodies[i] = m_world.CreateBody(bd);

                    m_bodies[i].CreateFixture(shape, 1.0f);

                    m_bodies[i].LinearVelocity = new b2Vec2(0.0f, -50.0f);
                }
            }
        }
开发者ID:h7ing,项目名称:CocosSharp,代码行数:29,代码来源:SphereStack.cs


示例4: InitPhysics

        void InitPhysics()
        {
            var gravity = new b2Vec2(0.0f, -10.0f);
            world = new b2World(gravity);

            world.SetAllowSleeping(true);
            world.SetContinuousPhysics(true);

            var def = new b2BodyDef();
            def.allowSleep = true;
            def.position = b2Vec2.Zero;
            def.type = b2BodyType.b2_staticBody;

            b2Body groundBody = world.CreateBody(def);
            groundBody.SetActive(true);

            b2EdgeShape groundBox = new b2EdgeShape();
            groundBox.Set(b2Vec2.Zero, new b2Vec2(900, 100));

            b2FixtureDef fd = new b2FixtureDef();
            fd.friction = 0.3f;
            fd.restitution = 0.1f;
            fd.shape = groundBox;

            groundBody.CreateFixture(fd);
        }
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:26,代码来源:IntroLayer.cs


示例5: b2EdgeShape

 public b2EdgeShape(b2EdgeShape e)
     : base((b2Shape)e)
 {
     m_vertex1 = e.m_vertex1;
     m_vertex2 = e.m_vertex2;
     m_vertex3 = e.m_vertex3;
     m_vertex0 = e.m_vertex0;
     m_hasVertex0 = e.m_hasVertex0;
     m_hasVertex3 = e.m_hasVertex3;
 }
开发者ID:homocury,项目名称:cocos2d-xna,代码行数:10,代码来源:b2EdgeShape.cs


示例6: b2EdgeShape

 public b2EdgeShape(b2EdgeShape e)
     : base((b2Shape)e)
 {
     Vertex1 = e.Vertex1;
     Vertex2 = e.Vertex2;
     Vertex3 = e.Vertex3;
     Vertex0 = e.Vertex0;
     HasVertex0 = e.HasVertex0;
     HasVertex3 = e.HasVertex3;
 }
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:10,代码来源:b2EdgeShape.cs


示例7: ContinuousTest

        public ContinuousTest()
        {
            {
                b2BodyDef bd  = new b2BodyDef();
                bd.position.Set(0.0f, 0.0f);
                b2Body body = m_world.CreateBody(bd);

                b2EdgeShape edge = new b2EdgeShape();

                edge.Set(new b2Vec2(-10.0f, 0.0f), new b2Vec2(10.0f, 0.0f));
                body.CreateFixture(edge, 0.0f);

                b2PolygonShape shape = new b2PolygonShape();
                shape.SetAsBox(0.2f, 1.0f, new b2Vec2(0.5f, 1.0f), 0.0f);
                body.CreateFixture(shape, 0.0f);
            }

#if true
            {
                b2BodyDef bd  = new b2BodyDef();
                bd.type = b2BodyType.b2_dynamicBody;
                bd.position.Set(0.0f, 20.0f);
                //bd.angle = 0.1f;

                b2PolygonShape shape = new b2PolygonShape();
                shape.SetAsBox(2.0f, 0.1f);

                m_body = m_world.CreateBody(bd);
                m_body.CreateFixture(shape, 1.0f);

                m_angularVelocity = Rand.RandomFloat(-50.0f, 50.0f);
                //m_angularVelocity = 46.661274f;
                m_body.LinearVelocity = new b2Vec2(0.0f, -100.0f);
                m_body.AngularVelocity = m_angularVelocity;
            }
#else
        {
            b2BodyDef bd  = new b2BodyDef();
            bd.type = b2BodyType.b2_dynamicBody;
            bd.position.Set(0.0f, 2.0f);
            b2Body body = m_world.CreateBody(bd);

            b2CircleShape shape = new b2CircleShape();
            shape.Position = b2Vec2.Zero;
            shape.Radius = 0.5f;
            body.CreateFixture(shape, 1.0f);

            bd.bullet = true;
            bd.position.Set(0.0f, 10.0f);
            body = m_world.CreateBody(bd);
            body.CreateFixture(shape, 1.0f);
            body.LinearVelocity = new b2Vec2(0.0f, -100.0f);
        }
#endif
        }
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:55,代码来源:ContinuousTest.cs


示例8: Pulleys

        public Pulleys()
        {
            float y = 16.0f;
            float L = 12.0f;
            float a = 1.0f;
            float b = 2.0f;

            b2Body ground = null;
            {
                b2BodyDef bd  = new b2BodyDef();
                ground = m_world.CreateBody(bd);

                b2EdgeShape edge = new b2EdgeShape();
                edge.Set(new b2Vec2(-40.0f, 0.0f), new b2Vec2(40.0f, 0.0f));
                //ground->CreateFixture(&shape, 0.0f);

                b2CircleShape circle = new b2CircleShape();
                circle.Radius = 2.0f;

                circle.Position = new b2Vec2(-10.0f, y + b + L);
                ground.CreateFixture(circle, 0.0f);

                circle.Position = new b2Vec2(10.0f, y + b + L);
                ground.CreateFixture(circle, 0.0f);
            }

            {

                b2PolygonShape shape = new b2PolygonShape();
                shape.SetAsBox(a, b);

                b2BodyDef bd  = new b2BodyDef();
                bd.type = b2BodyType.b2_dynamicBody;

                //bd.fixedRotation = true;
                bd.position.Set(-10.0f, y);
                b2Body body1 = m_world.CreateBody(bd);
                body1.CreateFixture(shape, 5.0f);

                bd.position.Set(10.0f, y);
                b2Body body2 = m_world.CreateBody(bd);
                body2.CreateFixture(shape, 5.0f);

                b2PulleyJointDef pulleyDef = new b2PulleyJointDef();
                b2Vec2 anchor1 = new b2Vec2(-10.0f, y + b);
                b2Vec2 anchor2 = new b2Vec2(10.0f, y + b);
                b2Vec2 groundAnchor1 = new b2Vec2(-10.0f, y + b + L);
                b2Vec2 groundAnchor2 = new b2Vec2(10.0f, y + b + L);
                pulleyDef.Initialize(body1, body2, groundAnchor1, groundAnchor2, anchor1, anchor2, 1.5f);

                m_joint1 = (b2PulleyJoint) m_world.CreateJoint(pulleyDef);
            }
        }
开发者ID:Karunp,项目名称:cocos2d-xna,代码行数:53,代码来源:Pulleys.cs


示例9: SensorTest

        public SensorTest()
        {
            {
                b2BodyDef bd  = new b2BodyDef();
                b2Body ground = m_world.CreateBody(bd);

                {
                    b2EdgeShape shape = new b2EdgeShape();
                    shape.Set(new b2Vec2(-40.0f, 0.0f), new b2Vec2(40.0f, 0.0f));
                    ground.CreateFixture(shape, 0.0f);
                }

#if false
            {
                b2FixtureDef sd = new b2FixtureDef();
                sd.SetAsBox(10.0f, 2.0f, new b2Vec2(0.0f, 20.0f), 0.0f);
                sd.isSensor = true;
                m_sensor = ground.CreateFixture(sd);
            }
#else
                {
                    b2CircleShape shape = new b2CircleShape();
                    shape.Radius = 5.0f;
                    shape.Position = new b2Vec2(0.0f, 10.0f);

                    b2FixtureDef fd = new b2FixtureDef();
                    fd.shape = shape;
                    fd.isSensor = true;
                    m_sensor = ground.CreateFixture(fd);
                }
#endif
            }

            {
                b2CircleShape shape = new b2CircleShape();
                shape.Radius = 1.0f;

                for (int i = 0; i < e_count; ++i)
                {
                    b2BodyDef bd  = new b2BodyDef();
                    bd.type = b2BodyType.b2_dynamicBody;
                    bd.position.Set(-10.0f + 3.0f * i, 20.0f);
                    bd.userData = i; //  m_touching[i];

                    m_touching[i] = false;
                    m_bodies[i] = m_world.CreateBody(bd);

                    m_bodies[i].CreateFixture(shape, 1.0f);
                }
            }
        }
开发者ID:h7ing,项目名称:CocosSharp,代码行数:51,代码来源:SensorTest.cs


示例10: Confined

        public Confined()
        {
            {
                b2BodyDef bd  = new b2BodyDef();
                b2Body ground = m_world.CreateBody(bd);

                b2EdgeShape shape = new b2EdgeShape();

                // Floor
                shape.Set(new b2Vec2(-10.0f, 0.0f), new b2Vec2(10.0f, 0.0f));
                ground.CreateFixture(shape, 0.0f);

                // Left wall
                shape.Set(new b2Vec2(-10.0f, 0.0f), new b2Vec2(-10.0f, 20.0f));
                ground.CreateFixture(shape, 0.0f);

                // Right wall
                shape.Set(new b2Vec2(10.0f, 0.0f), new b2Vec2(10.0f, 20.0f));
                ground.CreateFixture(shape, 0.0f);

                // Roof
                shape.Set(new b2Vec2(-10.0f, 20.0f), new b2Vec2(10.0f, 20.0f));
                ground.CreateFixture(shape, 0.0f);
            }

            float radius = 0.5f;
            b2CircleShape shape1 = new b2CircleShape();
            shape1.Position = b2Vec2.Zero;
            shape1.Radius = radius;

            b2FixtureDef fd = new b2FixtureDef();
            fd.shape = shape1;
            fd.density = 1.0f;
            fd.friction = 0.1f;

            for (int j = 0; j < e_columnCount; ++j)
            {
                for (int i = 0; i < e_rowCount; ++i)
                {
                    b2BodyDef bd  = new b2BodyDef();
                    bd.type = b2BodyType.b2_dynamicBody;
                    bd.position.Set(-10.0f + (2.1f * j + 1.0f + 0.01f * i) * radius, (2.0f * i + 1.0f) * radius);
                    b2Body body = m_world.CreateBody(bd);

                    body.CreateFixture(fd);
                }
            }

            m_world.Gravity = new b2Vec2(0.0f, 0.0f);
        }
开发者ID:h7ing,项目名称:CocosSharp,代码行数:50,代码来源:Confined.cs


示例11: VerticalStack

        //public const int e_columnCount = 1;
        //public const int e_rowCount = 1;

        public VerticalStack()
        {
            {
                b2BodyDef bd  = new b2BodyDef();
                b2Body ground = m_world.CreateBody(bd);

                b2EdgeShape shape = new b2EdgeShape();
                shape.Set(new b2Vec2(-40.0f, 0.0f), new b2Vec2(40.0f, 0.0f));
                ground.CreateFixture(shape, 0.0f);

                shape.Set(new b2Vec2(20.0f, 0.0f), new b2Vec2(20.0f, 20.0f));
                ground.CreateFixture(shape, 0.0f);
            }

            float[] xs = {0.0f, -10.0f, -5.0f, 5.0f, 10.0f};

            for (int j = 0; j < e_columnCount; ++j)
            {
                b2PolygonShape shape = new b2PolygonShape();
                shape.SetAsBox(0.5f, 0.5f);

                b2FixtureDef fd = new b2FixtureDef();
                fd.shape = shape;
                fd.density = 1.0f;
                fd.friction = 0.3f;

                for (int i = 0; i < e_rowCount; ++i)
                {
                    b2BodyDef bd  = new b2BodyDef();
                    bd.type = b2BodyType.b2_dynamicBody;

                    int n = j * e_rowCount + i;
                    Debug.Assert(n < e_rowCount * e_columnCount);
                    m_indices[n] = n;
                    bd.userData = m_indices[n];

                    float x = 0.0f;
                    //float32 x = RandomFloat(-0.02f, 0.02f);
                    //float32 x = i % 2 == 0 ? -0.025f : 0.025f;
                    bd.position.Set(xs[j] + x, 0.752f + 1.54f * i);
                    b2Body body = m_world.CreateBody(bd);

                    m_bodies[n] = body;

                    body.CreateFixture(fd);
                }
            }

            m_bullet = null;
        }
开发者ID:h7ing,项目名称:CocosSharp,代码行数:53,代码来源:VerticalStack.cs


示例12: Prismatic

        public Prismatic()
        {
            b2Body ground = null;
            {
                b2BodyDef bd  = new b2BodyDef();
                ground = m_world.CreateBody(bd);

                b2EdgeShape shape = new b2EdgeShape();
                shape.Set(new b2Vec2(-40.0f, 0.0f), new b2Vec2(40.0f, 0.0f));
                ground.CreateFixture(shape, 0.0f);
            }

            {
                b2PolygonShape shape = new b2PolygonShape();
                shape.SetAsBox(2.0f, 0.5f);

                b2BodyDef bd  = new b2BodyDef();
                bd.type = b2BodyType.b2_dynamicBody;
                bd.position.Set(-10.0f, 10.0f);
                bd.angle = 0.5f * b2Settings.b2_pi;
                bd.allowSleep = false;
                b2Body body = m_world.CreateBody(bd);
                body.CreateFixture(shape, 5.0f);

                b2PrismaticJointDef pjd = new b2PrismaticJointDef();

                // Bouncy limit
                b2Vec2 axis = new b2Vec2(2.0f, 1.0f);
                axis.Normalize();
                pjd.Initialize(ground, body, new b2Vec2(0.0f, 0.0f), axis);

                // Non-bouncy limit
                //pjd.Initialize(ground, body, b2Vec2(-10.0f, 10.0f), b2Vec2(1.0f, 0.0f));

                pjd.motorSpeed = 10.0f;
                pjd.maxMotorForce = 10000.0f;
                pjd.enableMotor = true;
                pjd.lowerTranslation = 0.0f;
                pjd.upperTranslation = 20.0f;
                pjd.enableLimit = true;

                m_joint = (b2PrismaticJoint) m_world.CreateJoint(pjd);
            }
        }
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:44,代码来源:Prismatic.cs


示例13: OneSidedPlatform

        public OneSidedPlatform()
        {
            // Ground
            {
                b2BodyDef bd  = new b2BodyDef();
                b2Body ground = m_world.CreateBody(bd);

                b2EdgeShape shape = new b2EdgeShape();
                shape.Set(new b2Vec2(-20.0f, 0.0f), new b2Vec2(20.0f, 0.0f));
                ground.CreateFixture(shape, 0.0f);
            }

            // Platform
            {
                b2BodyDef bd  = new b2BodyDef();
                bd.position.Set(0.0f, 10.0f);
                b2Body body = m_world.CreateBody(bd);

                b2PolygonShape shape = new b2PolygonShape();
                shape.SetAsBox(3.0f, 0.5f);
                m_platform = body.CreateFixture(shape, 0.0f);

                m_bottom = 10.0f - 0.5f;
                m_top = 10.0f + 0.5f;
            }

            // Actor
            {
                b2BodyDef bd  = new b2BodyDef();
                bd.type = b2BodyType.b2_dynamicBody;
                bd.position.Set(0.0f, 12.0f);
                b2Body body = m_world.CreateBody(bd);

                m_radius = 0.5f;
                b2CircleShape shape = new b2CircleShape();
                shape.Radius = m_radius;
                m_character = body.CreateFixture(shape, 20.0f);

                body.LinearVelocity = new b2Vec2(0.0f, -50.0f);

                m_state = State.e_unknown;
            }
        }
开发者ID:Karunp,项目名称:cocos2d-xna,代码行数:43,代码来源:OneSidedPlatform.cs


示例14: Chain

        public Chain()
        {
            b2Body ground = null;
            {
                b2BodyDef bd  = new b2BodyDef();
                ground = m_world.CreateBody(bd);

                b2EdgeShape shape = new b2EdgeShape();
                shape.Set(new b2Vec2(-40.0f, 0.0f), new b2Vec2(40.0f, 0.0f));
                ground.CreateFixture(shape, 0.0f);
            }

            {
                b2PolygonShape shape = new b2PolygonShape();
                shape.SetAsBox(0.6f, 0.125f);

                b2FixtureDef fd = new b2FixtureDef();
                fd.shape = shape;
                fd.density = 20.0f;
                fd.friction = 0.2f;

                b2RevoluteJointDef jd = new b2RevoluteJointDef();
                jd.CollideConnected = false;

                const float y = 25.0f;
                b2Body prevBody = ground;
                for (int i = 0; i < 30; ++i)
                {
                    b2BodyDef bd  = new b2BodyDef();
                    bd.type = b2BodyType.b2_dynamicBody;
                    bd.position.Set(0.5f + i, y);
                    b2Body body = m_world.CreateBody(bd);
                    body.CreateFixture(fd);

                    b2Vec2 anchor = new b2Vec2(i, y);
                    jd.Initialize(prevBody, body, anchor);
                    m_world.CreateJoint(jd);

                    prevBody = body;
                }
            }
        }
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:42,代码来源:Chain.cs


示例15: CircleBenchmarkTest

        public CircleBenchmarkTest()
        {
            b2BodyDef bd = new b2BodyDef();
            b2Body ground = m_world.CreateBody(bd);

            // Floor
            b2EdgeShape shape = new b2EdgeShape();
            shape.Set(new b2Vec2(-40.0f, 0.0f), new b2Vec2(40.0f, 0.0f));
            ground.CreateFixture(shape, 0.0f);

            // Left wall
            shape = new b2EdgeShape();
            shape.Set(new b2Vec2(-40.0f, 0.0f), new b2Vec2(-40.0f, 45.0f));
            ground.CreateFixture(shape, 0.0f);

            // Right wall
            shape = new b2EdgeShape();
            shape.Set(new b2Vec2(40.0f, 0.0f), new b2Vec2(40.0f, 45.0f));
            ground.CreateFixture(shape, 0.0f);

            // Roof
            shape = new b2EdgeShape();
            shape.Set(new b2Vec2(-40.0f, 45.0f), new b2Vec2(40.0f, 45.0f));
            ground.CreateFixture(shape, 0.0f);

            var sphere = new b2CircleShape();
            sphere.Radius = 1.0f;

            for (int i = 0; i < XCount; i++)
            {
                for (int j = 0; j < YCount; ++j)
                {
                    bd = new b2BodyDef();
                    bd.type = b2BodyType.b2_dynamicBody;
                    bd.position.Set(-38f + 2.1f * i, 2.0f + 2.0f * j);

                    var body = m_world.CreateBody(bd);
                    body.CreateFixture(sphere, 1.0f);
                }
            }
        }
开发者ID:Karunp,项目名称:cocos2d-xna,代码行数:41,代码来源:CircleBenchmarkTest.cs


示例16: BulletTest

        public BulletTest()
        {
            {
                b2BodyDef bd  = new b2BodyDef();
                bd.position.Set(0.0f, 0.0f);
                b2Body body = m_world.CreateBody(bd);

                b2EdgeShape edge = new b2EdgeShape();

                edge.Set(new b2Vec2(-10.0f, 0.0f), new b2Vec2(10.0f, 0.0f));
                body.CreateFixture(edge, 0.0f);

                b2PolygonShape shape = new b2PolygonShape();
                shape.SetAsBox(0.2f, 1.0f, new b2Vec2(0.5f, 1.0f), 0.0f);
                body.CreateFixture(shape, 0.0f);
            }

            {
                b2BodyDef bd  = new b2BodyDef();
                bd.type = b2BodyType.b2_dynamicBody;
                bd.position.Set(0.0f, 4.0f);

                b2PolygonShape box = new b2PolygonShape();
                box.SetAsBox(2.0f, 0.1f);

                m_body = m_world.CreateBody(bd);
                m_body.CreateFixture(box, 1.0f);

                box.SetAsBox(0.25f, 0.25f);

                //m_x = RandomFloat(-1.0f, 1.0f);
                m_x = 0.20352793f;
                bd.position.Set(m_x, 10.0f);
                bd.bullet = true;

                m_bullet = m_world.CreateBody(bd);
                m_bullet.CreateFixture(box, 100.0f);

                m_bullet.LinearVelocity = new b2Vec2(0.0f, -50.0f);
            }
        }
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:41,代码来源:BulletTest.cs


示例17: Pyramid

        public Pyramid()
        {
            {
                b2BodyDef bd  = new b2BodyDef();
                b2Body ground = m_world.CreateBody(bd);

                b2EdgeShape shape = new b2EdgeShape();
                shape.Set(new b2Vec2(-40.0f, 0.0f), new b2Vec2(40.0f, 0.0f));
                ground.CreateFixture(shape, 0.0f);
            }

            {
                float a = 0.5f;
                b2PolygonShape shape = new b2PolygonShape();
                shape.SetAsBox(a, a);

                b2Vec2 x = new b2Vec2(-7.0f, 0.75f);
                b2Vec2 y;
                b2Vec2 deltaX = new b2Vec2(0.5625f, 1.25f);
                b2Vec2 deltaY = new b2Vec2(1.125f, 0.0f);

                for (int i = 0; i < e_count; ++i)
                {
                    y = x;

                    for (int j = i; j < e_count; ++j)
                    {
                        b2BodyDef bd  = new b2BodyDef();
                        bd.type = b2BodyType.b2_dynamicBody;
                        bd.position = y;
                        b2Body body = m_world.CreateBody(bd);
                        body.CreateFixture(shape, 5.0f);

                        y += deltaY;
                    }

                    x += deltaX;
                }
            }
        }
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:40,代码来源:Pyramid.cs


示例18: ShapeEditing

        public ShapeEditing()
        {
            {
                b2BodyDef bd1  = new b2BodyDef();
                b2Body ground = m_world.CreateBody(bd1);

                b2EdgeShape shape1 = new b2EdgeShape();
                shape1.Set(new b2Vec2(-40.0f, 0.0f), new b2Vec2(40.0f, 0.0f));
                ground.CreateFixture(shape1, 0.0f);
            }

            b2BodyDef bd  = new b2BodyDef();
            bd.type = b2BodyType.b2_dynamicBody;
            bd.position.Set(0.0f, 10.0f);
            m_body = m_world.CreateBody(bd);

            b2PolygonShape shape = new b2PolygonShape();
            shape.SetAsBox(4.0f, 4.0f, new b2Vec2(0.0f, 0.0f), 0.0f);
            m_fixture1 = m_body.CreateFixture(shape, 10.0f);

            m_fixture2 = null;

            m_sensor = false;
        }
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:24,代码来源:ShapeEditing.cs


示例19: b2CollideEdgeAndCircle

        /// Compute the collision manifold between an edge and a circle.
        public static void b2CollideEdgeAndCircle(ref b2Manifold manifold,
                                        b2EdgeShape edgeA, ref b2Transform xfA,
                                        b2CircleShape circleB, ref b2Transform xfB)
        {
            manifold.pointCount = 0;

            // Compute circle in frame of edge
            b2Vec2 Q = b2Math.b2MulT(xfA, b2Math.b2Mul(xfB, circleB.Position));

            b2Vec2 A = edgeA.Vertex1, B = edgeA.Vertex2;
            b2Vec2 e = B - A;
            b2Vec2 diff;

            // Barycentric coordinates
            diff = B - Q;
            float u = b2Math.b2Dot(ref e, ref diff); // B - Q);
            diff = Q - A;
            float v = b2Math.b2Dot(ref e, ref diff); // Q - A);

            float radius = edgeA.Radius + circleB.Radius;

            b2ContactFeature cf = b2ContactFeature.Zero;
            cf.indexB = 0;
            cf.typeB = b2ContactFeatureType.e_vertex;

            // Region A
            if (v <= 0.0f)
            {
                b2Vec2 P = A;
                b2Vec2 d = Q - P;
                float dd = d.LengthSquared; //  b2Math.b2Dot(d, d);
                if (dd > radius * radius)
                {
                    return;
                }

                // Is there an edge connected to A?
                if (edgeA.HasVertex0)
                {
                    b2Vec2 A1 = edgeA.Vertex0;
                    b2Vec2 B1 = A;
                    b2Vec2 e1 = B1 - A1;
                    diff = B1 - Q;
                    float u1 = b2Math.b2Dot(ref e1, ref diff);

                    // Is the circle in Region AB of the previous edge?
                    if (u1 > 0.0f)
                    {
                        return;
                    }
                }

                cf.indexA = 0;
                cf.typeA = b2ContactFeatureType.e_vertex;
                manifold.pointCount = 1;
                manifold.type = b2ManifoldType.e_circles;
                manifold.localNormal.SetZero();
                manifold.localPoint = P;
                manifold.points[0].id.key = 0;
                manifold.points[0].id.Set(cf);
                manifold.points[0].localPoint = circleB.Position;
                return;
            }

            // Region B
            if (u <= 0.0f)
            {
                b2Vec2 P = B;
                b2Vec2 d = Q - P;
                float dd = d.LengthSquared; //  b2Math.b2Dot(d, d);
                if (dd > radius * radius)
                {
                    return;
                }

                // Is there an edge connected to B?
                if (edgeA.HasVertex3)
                {
                    b2Vec2 B2 = edgeA.Vertex3;
                    b2Vec2 A2 = B;
                    b2Vec2 e2 = B2 - A2;
                    diff = Q - A2;
                    float v2 = b2Math.b2Dot(ref e2, ref diff);

                    // Is the circle in Region AB of the next edge?
                    if (v2 > 0.0f)
                    {
                        return;
                    }
                }

                cf.indexA = 1;
                cf.typeA = b2ContactFeatureType.e_vertex;
                manifold.pointCount = 1;
                manifold.type = b2ManifoldType.e_circles;
                manifold.localNormal.SetZero();
                manifold.localPoint = P;
                manifold.points[0].id.key = 0;
                manifold.points[0].id.Set(cf);
//.........这里部分代码省略.........
开发者ID:CartBlanche,项目名称:cocos2d-xna,代码行数:101,代码来源:b2Collision.cs


示例20: Clone

 public override b2Shape Clone()
 {
     b2EdgeShape clone = new b2EdgeShape(this);
     return clone;
 }
开发者ID:homocury,项目名称:cocos2d-xna,代码行数:5,代码来源:b2EdgeShape.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Shapes.b2PolygonShape类代码示例发布时间:2022-05-24
下一篇:
C# Box2D.Vec2类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap