本文整理汇总了C#中CocosSharp.CCColor4B类的典型用法代码示例。如果您正苦于以下问题:C# CCColor4B类的具体用法?C# CCColor4B怎么用?C# CCColor4B使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CCColor4B类属于CocosSharp命名空间,在下文中一共展示了CCColor4B类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateGradient
/*
* TL TR
* 0----1 0,1,2,3 = index offsets for vertex indices
* | /|
* | / |
* | / |
* |/ |
* 2----3
* BL BR
*/
void GenerateGradient(CCSize textureSizeInPixels)
{
var gradientNode = new CCDrawNode();
var gradientAlpha = new CCColor4B(0, 0, 0,(byte)(0.7f * 255f));
CCV3F_C4B[] vertices = new CCV3F_C4B[6];
// Left triangle TL - 0
vertices[0].Vertices = new CCVertex3F(0, textureSizeInPixels.Height, 0);
vertices[0].Colors = CCColor4B.Transparent;
// Left triangle BL - 2
vertices[1].Vertices = new CCVertex3F(0, 0, 0);
vertices[1].Colors = gradientAlpha;
// Left triangle TR - 1
vertices[2].Vertices = new CCVertex3F(textureSizeInPixels.Width, textureSizeInPixels.Height, 0);
vertices[2].Colors = CCColor4B.Transparent;
// Right triangle BL - 2
vertices[3].Vertices = new CCVertex3F(0, 0, 0);
vertices[3].Colors = gradientAlpha;
// Right triangle BR - 3
vertices[4].Vertices = new CCVertex3F(textureSizeInPixels.Width, 0, 0);
vertices[4].Colors = gradientAlpha;
// Right triangle TR - 1
vertices[5].Vertices = new CCVertex3F(textureSizeInPixels.Width, textureSizeInPixels.Height, 0);
vertices[5].Colors = CCColor4B.Transparent;
gradientNode.DrawTriangleList(vertices);
gradientNode.Visit();
}
示例2: Background
public Background(CCSize size, CCColor4B color)
{
Color = new CCColor3B(color);
Opacity = color.A;
AnchorPoint = CCPoint.AnchorMiddle;
ContentSize = size;
}
示例3: SpriteWithColor
public SpriteWithColor(CCColor4B bgColor, CCSize textureSizeInPixels) : base ()
{
// 1: Create new CCRenderTexture
CCRenderTexture rt = new CCRenderTexture(textureSizeInPixels, textureSizeInPixels);
// 2: Call CCRenderTexture:begin
rt.BeginWithClear(bgColor);
// 3: Draw into the texture
// You'll add this later
GenerateGradient(textureSizeInPixels);
var noise = new CCSprite("images/Noise.png");
noise.AnchorPoint = CCPoint.AnchorLowerLeft;
noise.Position = CCPoint.Zero;
noise.BlendFunc = new CCBlendFunc(CCOGLES.GL_DST_COLOR, CCOGLES.GL_ZERO);
noise.Texture.SamplerState = Microsoft.Xna.Framework.Graphics.SamplerState.LinearWrap;
// To get the linear wrap to work correctly we have to set the TextureRectInPixels as well as ContentSize
noise.TextureRectInPixels = new CCRect(0, 0, textureSizeInPixels.Width, textureSizeInPixels.Height);
noise.ContentSize = noise.TextureRectInPixels.Size;
noise.Visit();
// 4: Call CCRenderTexture:end
rt.End();
this.Texture = rt.Texture;
}
示例4: AlignmentPanel
public AlignmentPanel(CCSize size, CCColor4B color)
{
Color = new CCColor3B(color);
Opacity = color.A;
//AnchorPoint = CCPoint.AnchorMiddle;
ContentSize = size;
}
示例5: CreateNativeLabel
internal static CCTexture2D CreateNativeLabel(string text, CCSize dimensions, CCTextAlignment hAlignment,
CCVerticalTextAlignment vAlignment, string fontName,
float fontSize, CCColor4B textColor)
{
if (string.IsNullOrEmpty(text))
{
return new CCTexture2D();
}
var font = CreateFont (fontName, fontSize);
if (dimensions.Equals(CCSize.Zero))
{
CreateBitmap(1, 1);
var ms = _graphics.MeasureString(text, font);
dimensions.Width = ms.Width;
dimensions.Height = ms.Height;
}
CreateBitmap((int)dimensions.Width, (int)dimensions.Height);
var stringFormat = new StringFormat();
switch (hAlignment)
{
case CCTextAlignment.Left:
stringFormat.Alignment = StringAlignment.Near;
break;
case CCTextAlignment.Center:
stringFormat.Alignment = StringAlignment.Center;
break;
case CCTextAlignment.Right:
stringFormat.Alignment = StringAlignment.Far;
break;
}
switch (vAlignment)
{
case CCVerticalTextAlignment.Top:
stringFormat.LineAlignment = StringAlignment.Near;
break;
case CCVerticalTextAlignment.Center:
stringFormat.LineAlignment = StringAlignment.Center;
break;
case CCVerticalTextAlignment.Bottom:
stringFormat.LineAlignment = StringAlignment.Far;
break;
}
_graphics.DrawString(text, font, _brush, new RectangleF(0, 0, dimensions.Width, dimensions.Height), stringFormat);
_graphics.Flush();
var texture = new CCTexture2D(SaveToStream(), CCSurfaceFormat.Bgra4444);
return texture;
}
示例6: ToVectorC4B
public static CCV3F_C4B ToVectorC4B(this b2Vec2 vec, CCColor4B color, int PTMRatio)
{
var v3f_c4b = new CCV3F_C4B();
v3f_c4b.Vertices.X = vec.x * PTMRatio;
v3f_c4b.Vertices.Y = vec.y * PTMRatio;
v3f_c4b.Colors = color;
return v3f_c4b;
}
示例7: DrawSolidPolygon
public override void DrawSolidPolygon(Box2D.Common.b2Vec2[] vertices, int vertexCount, Box2D.Common.b2Color color)
{
CCPoint[] verticesToPoint = new CCPoint[vertexCount];
CCColor4B Color = new CCColor4B (color.r, color.g, color.b, 255);
for (int i = 0; i < vertexCount; i++) {
verticesToPoint [i] = new CCPoint (vertices [i].x * 50f, vertices [i].y * 50f);
}
DrawNode.DrawPolygon (verticesToPoint, vertexCount, Color, 3f, Color);
}
示例8: Ball
public Ball(float x, float y, float r, CCColor4B c)
{
this.x = x;
this.y = y;
this.r = r;
this.color = c;
location = new CCPoint (x , y);
circle = new CCDrawNode ();
drawCircle ();
}
示例9: GenerateStripes
/*
* TL TR
* 0----1 0,1,2,3 = index offsets for vertex indices
* | /|
* | / |
* | / |
* |/ |
* 2----3
* BL BR
*/
void GenerateStripes (CCSize textureSizeInPixels, CCColor4B c2, int numberOfStripes)
{
var gradientNode = new CCDrawNode();
// Layer 1: Stripes
CCV3F_C4B[] vertices = new CCV3F_C4B[numberOfStripes*6];
var textureWidth = textureSizeInPixels.Width;
var textureHeight = textureSizeInPixels.Height;
int nVertices = 0;
float x1 = -textureHeight;
float x2;
float y1 = textureHeight;
float y2 = 0;
float dx = textureWidth / numberOfStripes * 2;
float stripeWidth = dx/2;
for (int i=0; i<numberOfStripes; i++)
{
x2 = x1 + textureHeight;
// Left triangle TL - 0
vertices[nVertices].Vertices = new CCVertex3F(x1, y1, 0);
vertices[nVertices++].Colors = c2;
// Left triangle BL - 2
vertices[nVertices].Vertices = new CCVertex3F(x1+stripeWidth, y1, 0);
vertices[nVertices++].Colors = c2;
// Left triangle TR - 1
vertices[nVertices].Vertices = new CCVertex3F(x2, y2, 0);
vertices[nVertices++].Colors = c2;
// Right triangle BL - 2
vertices[nVertices].Vertices = vertices[nVertices-2].Vertices;
vertices[nVertices++].Colors = c2;
// Right triangle BR - 3
vertices[nVertices].Vertices = vertices[nVertices-2].Vertices;
vertices[nVertices++].Colors = c2;
// Right triangle TR - 1
vertices[nVertices].Vertices = new CCVertex3F(x2+stripeWidth, y2, 0);
vertices[nVertices++].Colors = c2;
x1 += dx;
}
gradientNode.DrawTriangleList(vertices);
gradientNode.Visit();
}
示例10: CreateBitmap
private void CreateBitmap(int width, int height)
{
// if (_bitmap == null || (_bitmap.Width < width || _bitmap.Height < height))
// {
_bitmap = CCLabelUtilities.CreateBitmap (width, height);
//}
//if (_brush == null)
//{
_brush = CCColor4B.White;
//}
}
示例11: DrawPoint
public static void DrawPoint(CCPoint p, float size, CCColor4B color)
{
var verts = new CCPoint[4];
float hs = size / 2.0f;
verts[0] = p + new CCPoint(-hs, -hs);
verts[1] = p + new CCPoint(hs, -hs);
verts[2] = p + new CCPoint(hs, hs);
verts[3] = p + new CCPoint(-hs, hs);
DrawPoly(verts, 4, false, true, color);
}
示例12: RefreshColor
private void RefreshColor()
{
BackgroundNode.Cleanup();
CCColor4B CurrColor = new CCColor4B();
if (Status == ButtonStatus.Pressed)
{
CurrColor = ClickedColor;
}
else
{
CurrColor = NormalColor;
}
BackgroundNode.DrawRect(new CCRect(0, 0, ContentSize.Width, ContentSize.Height), CurrColor);
}
示例13: DrawCircle
public void DrawCircle(CCPoint center, float radius, int segments, CCColor4B color)
{
var cl = color;
float theta = 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; //we start at angle = 0
float y = 0;
var vert1 = new CCV3F_C4B(CCVertex3F.Zero, cl);
float tx = 0;
float ty = 0;
for (int i = 0; i < segments; i++)
{
vert1.Vertices.X = x + center.X;
vert1.Vertices.Y = y + center.Y;
AddLineVertex(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.Vertices.X = x + center.X;
vert1.Vertices.Y = y + center.Y;
AddLineVertex(vert1); // output vertex
}
dirty = true;
}
示例14: Draw
protected void Draw()
{
CCColor4B color = new CCColor4B(1.0f, 1.0f, 1.0f, 1.0f);
switch (_lineType)
{
case lineTypes.LINE_NONE:
break;
case lineTypes.LINE_TEMP:
drawNode.DrawLine(_tip, _pivot, color);
drawNode.DrawCircle(_pivot, 10, 10, color);
break;
case lineTypes.LINE_DASHED:
drawNode.DrawCircle(_pivot, 10, 10, color);
int segments = (int)(_lineLength / (_dash + _dashSpace));
float t = 0.0f;
float x_;
float y_;
for (int i = 0; i < segments + 1; i++)
{
x_ = _pivot.X + t * (_tip.X - _pivot.X);
y_ = _pivot.Y + t * (_tip.Y - _pivot.Y);
drawNode.DrawCircle(new CCPoint(x_, y_), 4, 6, color);
t += (float)1 / segments;
}
break;
}
//draw energy bar
color = new CCColor4B(0.0f, 0.0f, 0.0f, 1.0f);
drawNode.DrawLine(
new CCPoint(_energyLineX, _screenSize.Height * 0.1f),
new CCPoint(_energyLineX, _screenSize.Height * 0.9f),
color);
color = new CCColor4B(1.0f, 0.5f, 0.0f, 1.0f);
drawNode.DrawLine(
new CCPoint(_energyLineX, _screenSize.Height * 0.1f),
new CCPoint(_energyLineX, _screenSize.Height * 0.1f + _energy * _energyHeight),
color);
}
示例15: StripeWithColor
public StripeWithColor(CCColor4B c1, CCColor4B c2, CCSize textureSizeInPixels, int nStripes) : base ()
{
// 1: Create new CCRenderTexture
CCRenderTexture rt = new CCRenderTexture(textureSizeInPixels, textureSizeInPixels);
// 2: Call CCRenderTexture:begin
rt.BeginWithClear(c1);
// 3: Draw into the texture
// You'll add this later
GenerateStripes(textureSizeInPixels, c2, nStripes);
var noise = new CCSprite("images/Noise.png");
noise.AnchorPoint = CCPoint.AnchorLowerLeft;
noise.BlendFunc = new CCBlendFunc(CCOGLES.GL_DST_COLOR, CCOGLES.GL_ZERO);
noise.Visit();
// 4: Call CCRenderTexture:end
rt.End();
this.Texture = rt.Texture;
}