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

C# Common.b2Vec2类代码示例

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

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



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

示例1: 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


示例2: Set

 public virtual void Set(b2Vec2 v1, b2Vec2 v2)
 {
     Vertex1 = v1;
     Vertex2 = v2;
     HasVertex0 = false;
     HasVertex3 = false;
 }
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:7,代码来源:b2EdgeShape.cs


示例3: Draw

        protected override void Draw(Settings settings)
        {
            base.Draw(settings);

            b2Manifold manifold = new b2Manifold();
            b2Collision.b2CollidePolygons(manifold, m_polygonA, ref m_transformA, m_polygonB, ref m_transformB);

            b2WorldManifold worldManifold = new b2WorldManifold();
            worldManifold.Initialize(manifold, ref m_transformA, m_polygonA.Radius, ref m_transformB, m_polygonB.Radius);

            m_debugDraw.DrawString(5, m_textLine, "point count = {0}", manifold.pointCount);
            m_textLine += 15;

            {
                b2Color color = new b2Color(0.9f, 0.9f, 0.9f);
                b2Vec2[] v = new b2Vec2[b2Settings.b2_maxPolygonVertices];
                for (int i = 0; i < m_polygonA.VertexCount; ++i)
                {
                    v[i] = b2Math.b2Mul(m_transformA, m_polygonA.Vertices[i]);
                }
                m_debugDraw.DrawPolygon(v, m_polygonA.VertexCount, color);

                for (int i = 0; i < m_polygonB.VertexCount; ++i)
                {
                    v[i] = b2Math.b2Mul(m_transformB, m_polygonB.Vertices[i]);
                }
                m_debugDraw.DrawPolygon(v, m_polygonB.VertexCount, color);
            }

            for (int i = 0; i < manifold.pointCount; ++i)
            {
                m_debugDraw.DrawPoint(worldManifold.points[i], 4.0f, new b2Color(0.9f, 0.3f, 0.3f));
            }
        }
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:34,代码来源:PolyCollision.cs


示例4: JumpPad

        public JumpPad(b2Vec2 JumpImpuls, CCPoint Position, b2World gameWorld)
        {
            this.Texture = new CCTexture2D ("jumppad");
            this.Scale = SpriteScale;
            this.Position = Position;
            this.IsAntialiased = false;

            jumpImpuls = JumpImpuls;
            totalJumps = 0;

            //box2d
            b2BodyDef jumpPadDef = new b2BodyDef ();
            jumpPadDef.type = b2BodyType.b2_kinematicBody;
            jumpPadDef.position = new b2Vec2 ((Position.X + this.ScaledContentSize.Width/2)/PhysicsHandler.pixelPerMeter, (Position.Y + this.ScaledContentSize.Height/4) / PhysicsHandler.pixelPerMeter);
            JumpPadBody = gameWorld.CreateBody (jumpPadDef);

            b2PolygonShape jumpPadShape = new b2PolygonShape ();
            jumpPadShape.SetAsBox ((float)this.ScaledContentSize.Width / PhysicsHandler.pixelPerMeter / 2, (float)this.ScaledContentSize.Height / PhysicsHandler.pixelPerMeter / 4);// /4 weil die hitbox nur die hälfte der textur ist

            b2FixtureDef jumpPadFixture = new b2FixtureDef ();
            jumpPadFixture.shape = jumpPadShape;
            jumpPadFixture.density = 0.0f; //Dichte
            jumpPadFixture.restitution = 0f; //Rückprall
            jumpPadFixture.friction = 0f;
            jumpPadFixture.userData = WorldFixtureData.jumppad;
            JumpPadBody.CreateFixture (jumpPadFixture);
            //
        }
开发者ID:Nuckal777,项目名称:mapKnight,代码行数:28,代码来源:JumpPad.cs


示例5: Initialize

 public void Initialize(b2Body bA, b2Body bB, b2Vec2 anchor)
 {
     BodyA = bA;
     BodyB = bB;
     localAnchorA = BodyA.GetLocalPoint(anchor);
     localAnchorB = BodyB.GetLocalPoint(anchor);
 }
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:7,代码来源:b2FrictionJointDef.cs


示例6: b2Mat22

 /// Construct this matrix using scalars.
 public b2Mat22(float a11, float a12, float a21, float a22)
 {
     ex = b2Vec2.Zero;
     ey = b2Vec2.Zero;
     ex.x = a11; ex.y = a21;
     ey.x = a12; ey.y = a22;
 }
开发者ID:KogleDK,项目名称:cocos2d-xna-1,代码行数:8,代码来源:b2Mat22.cs


示例7: DrawFixture

        public void DrawFixture(b2Fixture fixture)
        {
            b2Color color = new b2Color(0.95f, 0.95f, 0.6f);
            b2Transform xf = fixture.Body.Transform;

            switch (fixture.ShapeType)
            {
                case b2ShapeType.e_circle:
                    {
                        b2CircleShape circle = (b2CircleShape) fixture.Shape;

                        b2Vec2 center = b2Math.b2Mul(xf, circle.Position);
                        float radius = circle.Radius;

                        m_debugDraw.DrawCircle(center, radius, color);
                    }
                    break;

                case b2ShapeType.e_polygon:
                    {
                        b2PolygonShape poly = (b2PolygonShape) fixture.Shape;
                        int vertexCount = poly.VertexCount;
                        Debug.Assert(vertexCount <= b2Settings.b2_maxPolygonVertices);
                        b2Vec2[] vertices = new b2Vec2[b2Settings.b2_maxPolygonVertices];

                        for (int i = 0; i < vertexCount; ++i)
                        {
                            vertices[i] = b2Math.b2Mul(xf, poly.Vertices[i]);
                        }

                        m_debugDraw.DrawPolygon(vertices, vertexCount, color);
                    }
                    break;
            }
        }
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:35,代码来源:PolyShapes.cs


示例8: b2ClipSegmentToLine

        /// Clipping for contact manifolds.
        public static int b2ClipSegmentToLine(b2ClipVertex[] vOut, b2ClipVertex[] vIn,
                                     b2Vec2 normal, float offset, byte vertexIndexA)
        {
            // Start with no output points
            int numOut = 0;

            // Calculate the distance of end points to the line
            float distance0 = b2Math.b2Dot(normal, vIn[0].v) - offset;
            float distance1 = b2Math.b2Dot(normal, vIn[1].v) - offset;

            // If the points are behind the plane
            if (distance0 <= 0.0f) vOut[numOut++] = vIn[0];
            if (distance1 <= 0.0f) vOut[numOut++] = vIn[1];

            // If the points are on different sides of the plane
            if (distance0 * distance1 < 0.0f)
            {
                // Find intersection point of edge and plane
                float interp = distance0 / (distance0 - distance1);
                vOut[numOut].v = vIn[0].v + interp * (vIn[1].v - vIn[0].v);

                // VertexA is hitting edgeB.
                vOut[numOut].id.indexA = vertexIndexA;
                vOut[numOut].id.indexB = vIn[0].id.indexB;
                vOut[numOut].id.typeA = b2ContactFeatureType.e_vertex;
                vOut[numOut].id.typeB = b2ContactFeatureType.e_face;
                ++numOut;
            }

            return numOut;
        }
开发者ID:homocury,项目名称:cocos2d-xna,代码行数:32,代码来源:b2Collision.cs


示例9: b2Mat22

 /// Construct this matrix using scalars.
 public b2Mat22(float a11, float a12, float a21, float a22)
 {
     _ex = new b2Vec2();
     _ey = new b2Vec2();
     _ex.x = a11; _ex.y = a21;
     _ey.x = a12; _ey.y = a22;
 }
开发者ID:homocury,项目名称:cocos2d-xna,代码行数:8,代码来源:b2Mat22.cs


示例10: Rope

        public Rope()
        {
            const int N = 40;
            b2Vec2[] vertices = new b2Vec2[N];
            float[] masses = new float[N];

            for (int i = 0; i < N; ++i)
            {
                vertices[i].Set(0.0f, 20.0f - 0.25f * i);
                masses[i] = 1.0f;
            }
            masses[0] = 0.0f;
            masses[1] = 0.0f;

            b2RopeDef def = new b2RopeDef();
            def.vertices = vertices;
            def.count = N;
            def.gravity.Set(0.0f, -10.0f);
            def.masses = masses;
            def.damping = 0.1f;
            def.k2 = 1.0f;
            def.k3 = 0.5f;

            m_rope.Initialize(def);

            m_angle = 0.0f;
            m_rope.SetAngle(m_angle);
        }
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:28,代码来源:Rope.cs


示例11: Set

 public virtual void Set(b2Vec2 v1, b2Vec2 v2)
 {
     m_vertex1 = v1;
     m_vertex2 = v2;
     m_hasVertex0 = false;
     m_hasVertex3 = false;
 }
开发者ID:CartBlanche,项目名称:cocos2d-xna,代码行数:7,代码来源:b2EdgeShape.cs


示例12: WorldToScreen

 public static CCPoint WorldToScreen(b2Vec2 worldPos, CCPoint actualPosition, float actualScale, CCSize wSize)
 {
     worldPos *= actualScale;
     CCPoint layerOffset = actualPosition;
     CCPoint p = new CCPoint(worldPos.x + layerOffset.X, worldPos.y + layerOffset.Y);
     p.Y = wSize.Height - p.Y;
     return p;
 }
开发者ID:netonjm,项目名称:RubeLoader,代码行数:8,代码来源:RubeBasicLayer.cs


示例13: SetTarget

 public virtual void SetTarget(b2Vec2 target)
 {
     if (m_bodyB.IsAwake() == false)
     {
         m_bodyB.SetAwake(true);
     }
     m_targetA = target;
 }
开发者ID:Karunp,项目名称:cocos2d-xna,代码行数:8,代码来源:b2MouseJoint.cs


示例14: Initialize

 /// Initialize the bodies, anchors, and reference angle using a world
 /// anchor point.
 public void Initialize(b2Body bA, b2Body bB, b2Vec2 anchor)
 {
     BodyA = bA;
     BodyB = bB;
     localAnchorA = BodyA.GetLocalPoint(anchor);
     localAnchorB = BodyB.GetLocalPoint(anchor);
     referenceAngle = BodyB.Angle - BodyA.Angle;
 }
开发者ID:Karunp,项目名称:cocos2d-xna,代码行数:10,代码来源:b2WeldJointDef.cs


示例15: CreateChain

 public virtual void CreateChain(b2Vec2[] vertices, int count)
 {
     Count = count;
     Vertices = new b2Vec2[count];
     Array.Copy(vertices, Vertices, count);
     HasPrevVertex = false;
     HasNextVertex = false;
 }
开发者ID:h7ing,项目名称:CocosSharp,代码行数:8,代码来源:b2ChainShape.cs


示例16: DrawPoint

        public void DrawPoint(b2Vec2 aP, float aSize, b2Color aColor)
        {
            CCDrawingPrimitives.Begin();

            CCDrawingPrimitives.DrawPoint(new CCPoint(mRatio * aP.x, mRatio * aP.y), 1, new CCColor4B(aColor.r, aColor.g, aColor.b, 1));

            CCDrawingPrimitives.End();
        }
开发者ID:netonjm,项目名称:RubeLoader,代码行数:8,代码来源:Box2dDebugDraw.cs


示例17: CreateChain

 public virtual void CreateChain(b2Vec2[] vertices, int count)
 {
     m_count = count;
     m_vertices = new b2Vec2[count];
     Array.Copy(m_vertices, vertices, count);
     m_hasPrevVertex = false;
     m_hasNextVertex = false;
 }
开发者ID:huaqiangs,项目名称:cocos2d-xna,代码行数:8,代码来源:b2ChainShape.cs


示例18: DrawPolygon

 public override void DrawPolygon(b2Vec2[] vertices, int vertexCount, b2Color color)
 {
     b2Vec2[] alt = new b2Vec2[vertexCount];
     for (int i = 0; i < vertexCount; i++)
     {
         alt[i] = vertices[i] * PTMRatio + _Center;
     }
     CCDrawingPrimitives.DrawPoly(alt, vertexCount, true, color);
 }
开发者ID:eickegao,项目名称:cocos2d-xna,代码行数:9,代码来源:CCDraw.cs


示例19: Defaults

 public void Defaults()
 {
     localCenter = new b2Vec2();
     c0 = new b2Vec2();
     c = new b2Vec2();
     a0 = 0f;
     a = 0f;
     alpha0 = 0f;
 }
开发者ID:homocury,项目名称:cocos2d-xna,代码行数:9,代码来源:b2Sweep.cs


示例20: DrawCircle

        public override void DrawCircle(b2Vec2 aCenter, float aRadius, b2Color aColor)
        {
            CCDrawingPrimitives.Begin();

            CCDrawingPrimitives.DrawCircle(new CCPoint(mRatio * aCenter.x, mRatio * aCenter.y),
                aRadius, 0, DEBUG_DRAW_CIRCLE_SEGMENTS, false,
                new CCColor4B(aColor.r, aColor.g, aColor.b, 1));

            CCDrawingPrimitives.End();
        }
开发者ID:netonjm,项目名称:RubeLoader,代码行数:10,代码来源:Box2dDebugDraw.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Dynamics.b2BodyDef类代码示例发布时间:2022-05-24
下一篇:
C# Common.b2Transform类代码示例发布时间: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