本文整理汇总了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++;
}
}
示例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;
}
示例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);
}
}