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


C# Common.b2Color类代码示例

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


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

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

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

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

示例4: Draw

        public virtual void Draw(b2Draw draw)
        {
            b2Color c = new b2Color(0.4f, 0.5f, 0.7f);

            for (int i = 0; i < m_count - 1; ++i)
            {
                draw.DrawSegment(m_ps[i], m_ps[i + 1], c);
            }
        }
开发者ID:homocury,项目名称:cocos2d-xna,代码行数:9,代码来源:b2Rope.cs

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

示例6: DrawSolidPolygon

 public override void DrawSolidPolygon(b2Vec2[] vertices, int vertexCount, b2Color color)
 {
     _list.Count = vertexCount;
     var alt = _list.Elements;
     for (int i = 0; i < vertexCount; i++)
     {
         alt[i] = vertices[i] * PTMRatio + _Center;
     }
     CCDrawingPrimitives.DrawSolidPoly(alt, vertexCount, color);
 }
开发者ID:nilcrabaniel,项目名称:cocos2d-xna,代码行数:10,代码来源:CCDraw.cs

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

示例8: DrawPoints

 public static void DrawPoints(b2Vec2[] points, int numberOfPoints, float size, b2Color color)
 {
     CCColor4B ccolor = new CCColor4B(color.r, color.g, color.b, 255);
     CCPoint pt = CCPoint.Zero;
     for (int i = 0; i < numberOfPoints; i++)
     {
         pt.X = points[i].x;
         pt.Y = points[i].y;
         DrawPoint(pt, size, ccolor);
     }
 }
开发者ID:nilcrabaniel,项目名称:cocos2d-xna,代码行数:11,代码来源:CCDrawingPrimitives.cs

示例9: DrawAABB

        public void DrawAABB(b2AABB aAabb, b2Color aColor)
        {
            mVertices[0] = new CCPoint(aAabb.LowerBound.x * mRatio, aAabb.LowerBound.y * mRatio);
            mVertices[1] = new CCPoint(aAabb.UpperBound.x * mRatio, aAabb.LowerBound.y * mRatio);
            mVertices[2] = new CCPoint(aAabb.UpperBound.x * mRatio, aAabb.UpperBound.y * mRatio);
            mVertices[3] = new CCPoint(aAabb.LowerBound.x * mRatio, aAabb.UpperBound.y * mRatio);

            CCDrawingPrimitives.Begin();
            CCDrawingPrimitives.DrawPoly(mVertices, 8, true, new CCColor4B(aColor.r, aColor.g, aColor.b, 1));
            CCDrawingPrimitives.End();
        }
开发者ID:netonjm,项目名称:RubeLoader,代码行数:11,代码来源:Box2dDebugDraw.cs

示例10: DrawPolygon

        public override void DrawPolygon(b2Vec2[] vertices, int vertexCount, b2Color color)
        {

            for (int i = 0; i < vertexCount - 1; i++)
            {
                DrawNode.AddLineVertex(vertices[i].ToVectorC4B(color.ToCCColor4B(), PTMRatio));
                DrawNode.AddLineVertex(vertices[i+1].ToVectorC4B(color.ToCCColor4B(), PTMRatio));

            }

            DrawNode.AddLineVertex(vertices[vertexCount - 1].ToVectorC4B(color.ToCCColor4B(), PTMRatio));
            DrawNode.AddLineVertex(vertices[0].ToVectorC4B(color.ToCCColor4B(), PTMRatio));
        }
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:13,代码来源:Box2DDebug.cs

示例11: Draw

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

            for (int i = 0; i < e_actorCount; ++i)
            {
                Actor actor = m_actors[i];
                if (actor.proxyId == b2_nullNode)
                    continue;

                b2Color c = new b2Color(0.9f, 0.9f, 0.9f);
                if (actor == m_rayActor && actor.overlap)
                {
                    c.Set(0.9f, 0.6f, 0.6f);
                }
                else if (actor == m_rayActor)
                {
                    c.Set(0.6f, 0.9f, 0.6f);
                }
                else if (actor.overlap)
                {
                    c.Set(0.6f, 0.6f, 0.9f);
                }

                m_debugDraw.DrawAABB(actor.aabb, c);
            }

            b2Color cc = new b2Color(0.7f, 0.7f, 0.7f);
            m_debugDraw.DrawAABB(m_queryAABB, cc);

            m_debugDraw.DrawSegment(m_rayCastInput.p1, m_rayCastInput.p2, cc);

            b2Color c1 = new b2Color(0.2f, 0.9f, 0.2f);
            b2Color c2 = new b2Color(0.9f, 0.2f, 0.2f);
            m_debugDraw.DrawPoint(m_rayCastInput.p1, 6.0f, c1);
            m_debugDraw.DrawPoint(m_rayCastInput.p2, 6.0f, c2);

            if (m_rayActor != null)
            {
                b2Color cr = new b2Color(0.2f, 0.2f, 0.9f);
                b2Vec2 p = m_rayCastInput.p1 + m_rayActor.fraction * (m_rayCastInput.p2 - m_rayCastInput.p1);
                m_debugDraw.DrawPoint(p, 6.0f, cr);
            }

            {
                int height = m_tree.GetHeight();
                m_debugDraw.DrawString(5, m_textLine, "dynamic tree height = {0}", height);
                m_textLine += 15;
            }
        }
开发者ID:h7ing,项目名称:CocosSharp,代码行数:50,代码来源:DynamicTreeTest.cs

示例12: DrawPolygon

        public override void DrawPolygon(b2Vec2[] aVertices, int aVertexCount, b2Color aColor)
        {
            for (int i = 0; i < DEBUG_DRAW_MAX_VERTICES && i < aVertexCount; i++)
                mVertices[i] = new CCPoint(mRatio * aVertices[i].x, mRatio * aVertices[i].y);

            CCPoint[] ar = new CCPoint[aVertices.Length];
            for (int i = 0; i < aVertices.Length; i++)
            {
                ar[i] = new CCPoint(aVertices[i].x, aVertices[i].y);
            }

            CCDrawingPrimitives.Begin();
            CCDrawingPrimitives.DrawPoly(ar, aVertexCount, true, new CCColor4B(aColor.r, aColor.g, aColor.b, 1));
            CCDrawingPrimitives.End();
        }
开发者ID:netonjm,项目名称:RubeLoader,代码行数:15,代码来源:Box2dDebugDraw.cs

示例13: DrawPolygon

        public override void DrawPolygon(b2Vec2[] vertices, int vertexCount, b2Color color)
        {
            if (!_primitiveBatch.IsReady())
            {
                throw new InvalidOperationException("BeginCustomDraw must be called before drawing anything.");
            }
            for (int i = 0; i < vertexCount - 1; i++)
            {
                _primitiveBatch.AddVertex(vertices[i].ToVector2(), color.ToColor(), PrimitiveType.LineList);
                _primitiveBatch.AddVertex(vertices[i + 1].ToVector2(), color.ToColor(), PrimitiveType.LineList);
            }

            _primitiveBatch.AddVertex(vertices[vertexCount - 1].ToVector2(), color.ToColor(), PrimitiveType.LineList);
            _primitiveBatch.AddVertex(vertices[0].ToVector2(), color.ToColor(), PrimitiveType.LineList);
        }
开发者ID:p07r0457,项目名称:cocos2d-xna,代码行数:15,代码来源:Cocos2DDebugDraw.cs

示例14: Draw

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

            b2DistanceInput input = b2DistanceInput.Create();
            input.proxyA.Set(m_polygonA, 0);
            input.proxyB.Set(m_polygonB, 0);
            input.transformA = m_transformA;
            input.transformB = m_transformB;
            input.useRadii = true;
            b2SimplexCache cache = b2SimplexCache.Create();
            cache.count = 0;
            b2DistanceOutput output = new b2DistanceOutput();
            b2Simplex.b2Distance(ref output, ref cache, ref input);

            m_debugDraw.DrawString(5, m_textLine, "distance = {0}", output.distance);
            m_textLine += 15;

            m_debugDraw.DrawString(5, m_textLine, "iterations = {0}", output.iterations);
            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);
            }

            b2Vec2 x1 = output.pointA;
            b2Vec2 x2 = output.pointB;

            b2Color c1 = new b2Color(1.0f, 0.0f, 0.0f);
            m_debugDraw.DrawPoint(x1, 4.0f, c1);

            b2Color c2 = new b2Color(1.0f, 1.0f, 0.0f);
            m_debugDraw.DrawPoint(x2, 4.0f, c2);
        }
开发者ID:p07r0457,项目名称:cocos2d-xna,代码行数:46,代码来源:DistanceTest.cs

示例15: DrawSolidPolygon

        public override void DrawSolidPolygon(b2Vec2[] vertices, int vertexCount, b2Color color)
        {

            if (vertexCount == 2)
            {
                DrawPolygon(vertices, vertexCount, color);
                return;
            }

            var colorFill = color.ToCCColor4B() * 0.5f;

            for (int i = 1; i < vertexCount - 1; i++)
            {
                DrawNode.AddLineVertex(vertices[0].ToVectorC4B(color.ToCCColor4B(), PTMRatio));
                DrawNode.AddLineVertex(vertices[i].ToVectorC4B(color.ToCCColor4B(), PTMRatio));
                DrawNode.AddLineVertex(vertices[i + 1].ToVectorC4B(color.ToCCColor4B(), PTMRatio));

            }

            DrawPolygon(vertices, vertexCount, color);
        }
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:21,代码来源:Box2DDebug.cs


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