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


C# CCColor4B.ToColor方法代码示例

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


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

示例1: AddVertex

		public void AddVertex(ref CCVector2 vertex, CCColor4B color, PrimitiveType primitiveType)
        {
            if (!hasBegun)
            {
                throw new InvalidOperationException("Begin must be called before AddVertex can be called.");
            }

            if (primitiveType == PrimitiveType.LineStrip || primitiveType == PrimitiveType.TriangleStrip)
            {
                throw new NotSupportedException("The specified primitiveType is not supported by PrimitiveBatch.");
            }

            if (primitiveType == PrimitiveType.TriangleList)
            {
                if (triangleVertsCount >= triangleVertices.Length)
                {
                    FlushTriangles();
                }
				triangleVertices[triangleVertsCount].Position = new Vector3(vertex.ToVector2(), -0.1f);
				triangleVertices[triangleVertsCount].Color = color.ToColor();
                triangleVertsCount++;
            }

            if (primitiveType == PrimitiveType.LineList)
            {
                if (lineVertsCount >= lineVertices.Length)
                {
                    FlushLines();
                }
				lineVertices[lineVertsCount].Position = new Vector3(vertex.ToVector2(), 0f);
				lineVertices[lineVertsCount].Color = color.ToColor();
                lineVertsCount++;
            }
        }
开发者ID:h7ing,项目名称:CocosSharp,代码行数:34,代码来源:CCPrimitiveBatch.cs

示例2: DrawSolidArc

        // Used for drawing line caps
        public void DrawSolidArc(CCPoint pos, float radius, float startAngle, float sweepAngle, CCColor4B color)
        {
            var cl = color.ToColor();

            int segments = (int)(10 * (float)Math.Sqrt(radius));  //<- Let's try to guess at # segments for a reasonable smoothness

            float theta = sweepAngle / (segments - 1);// MathHelper.Pi * 2.0f / segments;
            float tangetial_factor = (float)Math.Tan(theta);   //calculate the tangential factor 

            float radial_factor = (float)Math.Cos(theta);   //calculate the radial factor 

            float x = radius * (float)Math.Cos(startAngle);   //we now start at the start angle
            float y = radius * (float)Math.Sin(startAngle); 

            var verticeCenter = new VertexPositionColor(new Vector3(pos.X, pos.Y, 0), cl);
            var vert1 = new VertexPositionColor(Vector3.Zero, cl);
            float tx = 0;
            float ty = 0;

            for (int i = 0; i < segments - 1; i++)
            {
                triangleVertices.Add(verticeCenter);

                vert1.Position.X = x + pos.X;
                vert1.Position.Y = y + pos.Y;
                triangleVertices.Add(vert1); // output vertex

                //calculate the tangential vector 
                //remember, the radial vector is (x, y) 
                //to get the tangential vector we flip those coordinates and negate one of them 
                tx = -y;
                ty = x;

                //add the tangential vector 
                x += tx * tangetial_factor;
                y += ty * tangetial_factor;

                //correct using the radial factor 
                x *= radial_factor;
                y *= radial_factor;

                vert1.Position.X = x + pos.X;
                vert1.Position.Y = y + pos.Y;
                triangleVertices.Add(vert1); // output vertex
            }

            dirty = true;
        }
开发者ID:netonjm,项目名称:CocosSharp,代码行数:49,代码来源:CCDrawNode.cs

示例3: SetTile

        public void SetTile(CCColor4B tile, CCGridSize position)
        {
            Debug.Assert(TGAInfo != null, "tgaInfo must not be nil");
            Debug.Assert(PositionToAtlasIndex != null, "posToAtlasIndex must not be nil");
            Debug.Assert(position.X < TGAInfo.Width, "Invalid position.x");
            Debug.Assert(position.Y < TGAInfo.Height, "Invalid position.x");
            Debug.Assert(tile.R != 0, "R component must be non 0");

            Color value = TGAInfo.ImageData[position.X + position.Y * TGAInfo.Width];
            if (value.R == 0)
            {
                CCLog.Log("CocosSharp: Value.r must be non 0.");
            }
            else
            {
                TGAInfo.ImageData[position.X + position.Y * TGAInfo.Width] = new Color(tile.R, tile.G, tile.B, tile.A);

                // XXX: this method consumes a lot of memory
                // XXX: a tree of something like that shall be implemented
                int num = PositionToAtlasIndex[position];
                UpdateAtlasValueAt(position, tile.ToColor(), num);
            }
        }
开发者ID:KerwinMa,项目名称:CocosSharp,代码行数:23,代码来源:CCTileMapAtlas.cs


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