本文整理汇总了C#中Cocos2D.CCColor4B类的典型用法代码示例。如果您正苦于以下问题:C# CCColor4B类的具体用法?C# CCColor4B怎么用?C# CCColor4B使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CCColor4B类属于Cocos2D命名空间,在下文中一共展示了CCColor4B类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: 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();
texture.InitWithStream (SaveToStream(), Microsoft.Xna.Framework.Graphics.SurfaceFormat.Bgra4444);
return texture;
}
开发者ID:Karunp,项目名称:cocos2d-xna,代码行数:60,代码来源:CCLabelUtilities-Gdi.cs
示例2: DrawLine
public static void DrawLine(CCPoint origin, CCPoint destination, CCColor4B color)
{
var c = new Color(color.R, color.G, color.B, color.A);
m_Batch.AddVertex(new Vector2(origin.X, origin.Y), c, PrimitiveType.LineList);
m_Batch.AddVertex(new Vector2(destination.X, destination.Y), c, PrimitiveType.LineList);
}
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:7,代码来源:CCDrawingPrimitives.cs
示例3: DrawPoints
public static void DrawPoints(CCPoint[] points, int numberOfPoints, float size, CCColor4B color)
{
for (int i = 0; i < numberOfPoints; i++)
{
DrawPoint(points[i], size, color);
}
}
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:7,代码来源:CCDrawingPrimitives.cs
示例4: InitWithDuration
/// <summary>
/// initializes the transition with a duration and with an RGB color
/// </summary>
protected virtual bool InitWithDuration(float duration, CCScene scene, CCColor3B color)
{
if (base.InitWithDuration(duration, scene))
{
m_tColor = new CCColor4B {R = color.R, G = color.G, B = color.B, A = 0};
}
return true;
}
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:11,代码来源:CCTransitionFade.cs
示例5: CCC4FFromCCC4B
public static CCColor4F CCC4FFromCCC4B(CCColor4B byteColor)
{
CCColor4F color;
color.R = CCColorFloatFromByte(byteColor.R);
color.G = CCColorFloatFromByte(byteColor.G);
color.B = CCColorFloatFromByte(byteColor.B);
color.A = CCColorFloatFromByte(byteColor.A);
return color;
}
开发者ID:rtabbara,项目名称:Cocos3D-XNA,代码行数:9,代码来源:LCC3ColorUtil.cs
示例6: 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
示例7: DrawRect
public static void DrawRect(CCRect rect, CCColor4B color)
{
float x1 = rect.MinX;
float y1 = rect.MinY;
float x2 = rect.MaxX;
float y2 = rect.MaxY;
DrawLine(new CCPoint(x1, y1), new CCPoint(x2, y1), color);
DrawLine(new CCPoint(x2, y1), new CCPoint(x2, y2), color);
DrawLine(new CCPoint(x2, y2), new CCPoint(x1, y2), color);
DrawLine(new CCPoint(x1, y2), new CCPoint(x1, y1), color);
}
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:12,代码来源:CCDrawingPrimitives.cs
示例8: 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);
}
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:13,代码来源:CCDrawingPrimitives.cs
示例9: 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 = new CCColor4B(Microsoft.Xna.Framework.Color.White);
//}
}
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:13,代码来源:CCLabel-CoreGraphics.cs
示例10: DrawCircle
public void DrawCircle(CCPoint center, float radius, float angle, int segments, CCColor4B color)
{
float increment = MathHelper.Pi * 2.0f / segments;
double theta = 0.0;
CCPoint v1;
CCPoint v2 = CCPoint.Zero;
List<CCPoint> verts = new List<CCPoint>();
for (int i = 0; i < segments; i++)
{
v1 = center + new CCPoint((float)Math.Cos(theta), (float)Math.Sin(theta)) * radius;
v2 = center + new CCPoint((float)Math.Cos(theta + increment), (float)Math.Sin(theta + increment)) * radius;
verts.Add(v1);
theta += increment;
}
CCColor4F cf = new CCColor4F(color.R/255f, color.G/255f, color.B/255f, color.A/255f);
DrawPolygon(verts.ToArray(), verts.Count, cf, 0, new CCColor4F(0f, 0f, 0f, 0f));
}
开发者ID:liwq-net,项目名称:UIFactory,代码行数:19,代码来源:CCDrawNode.cs
示例11: DrawPoly
/// <summary>
/// draws a poligon given a pointer to CCPoint coordiantes and the number of vertices measured in points.
/// The polygon can be closed or open
/// </summary>
public static void DrawPoly(CCPoint[] vertices, int numOfVertices, bool closePolygon, CCColor4B color)
{
DrawPoly(vertices, numOfVertices, closePolygon, false, color);
}
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:8,代码来源:CCDrawingPrimitives.cs
示例12: CCLayerColor
/// <summary>
/// creates a CCLayer with color. Width and height are the window size.
/// </summary>
public CCLayerColor (CCColor4B color) : this()
{
InitWithColor(color);
}
开发者ID:pekayatt,项目名称:cocos2d-xna,代码行数:7,代码来源:CCLayerColor.cs
示例13: InitWithColor
/// <summary>
/// initializes a CCLayer with color
/// </summary>
public virtual bool InitWithColor(CCColor4B color)
{
CCSize s = CCDirector.SharedDirector.WinSize;
return InitWithColor(color, s.Width, s.Height);
}
开发者ID:pekayatt,项目名称:cocos2d-xna,代码行数:8,代码来源:CCLayerColor.cs
示例14: DrawPie
public static void DrawPie (CCRect rect, int startAngle, int sweepAngle, CCColor4B color)
{
DrawEllipticalArc(rect, startAngle, sweepAngle, true, color);
}
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:4,代码来源:CCDrawingPrimitives.cs
示例15: Draw
public override void Draw()
{
var map = (CCTMXTiledMap) GetChildByTag(kTagTileMap);
CCTMXObjectGroup group = map.ObjectGroupNamed("Object Group 1");
List<Dictionary<string, string>> objects = group.Objects;
foreach (var dict in objects)
{
float x = float.Parse(dict["x"]);
float y = float.Parse(dict["y"]);
float width = (dict.ContainsKey("width") ? float.Parse(dict["width"]) : 0f);
float height = (dict.ContainsKey("height") ? float.Parse(dict["height"]) : 0f);
var color = new CCColor4B(255, 255, 0, 255);
CCDrawingPrimitives.Begin();
CCDrawingPrimitives.DrawLine(this.NodeToWorldTransform().Transform(new CCPoint(x, y)), this.NodeToWorldTransform().Transform(new CCPoint((x + width), y)), color);
CCDrawingPrimitives.DrawLine(this.NodeToWorldTransform().Transform(new CCPoint((x + width), y)), this.NodeToWorldTransform().Transform(new CCPoint((x + width), (y + height))), color);
CCDrawingPrimitives.DrawLine(this.NodeToWorldTransform().Transform(new CCPoint((x + width), (y + height))), this.NodeToWorldTransform().Transform(new CCPoint(x, (y + height))), color);
CCDrawingPrimitives.DrawLine(this.NodeToWorldTransform().Transform(new CCPoint(x, (y + height))), this.NodeToWorldTransform().Transform(new CCPoint(x, y)), color);
CCDrawingPrimitives.End();
//glLineWidth(1);
}
}
开发者ID:261117370,项目名称:cocos2d-xna,代码行数:25,代码来源:TileMapTest.cs
示例16: buildAttributedString
private static NSMutableAttributedString buildAttributedString(string text, CTFont font,
CCColor4B? fontColor=null)
{
// Create a new attributed string definition
var ctAttributes = new CTStringAttributes ();
// Font attribute
ctAttributes.Font = font;
// -- end font
if (fontColor.HasValue) {
// Font color
var fc = fontColor.Value;
var cgColor = new CGColor(fc.R / 255f,
fc.G / 255f,
fc.B / 255f,
fc.A / 255f);
ctAttributes.ForegroundColor = cgColor;
ctAttributes.ForegroundColorFromContext = false;
// -- end font Color
}
if (underLine) {
// Underline
#if MACOS
int single = (int)MonoMac.AppKit.NSUnderlineStyle.Single;
int solid = (int)MonoMac.AppKit.NSUnderlinePattern.Solid;
var attss = single | solid;
ctAttributes.UnderlineStyleValue = attss;
#else
ctAttributes.UnderlineStyleValue = 1;
#endif
// --- end underline
}
if (strikeThrough) {
// StrikeThrough
// NSColor bcolor = NSColor.Blue;
// NSObject bcolorObject = new NSObject(bcolor.Handle);
// attsDic.Add(NSAttributedString.StrikethroughColorAttributeName, bcolorObject);
// #if MACOS
// int stsingle = (int)MonoMac.AppKit.NSUnderlineStyle.Single;
// int stsolid = (int)MonoMac.AppKit.NSUnderlinePattern.Solid;
// var stattss = stsingle | stsolid;
// var stunderlineObject = NSNumber.FromInt32(stattss);
// #else
// var stunderlineObject = NSNumber.FromInt32 (1);
// #endif
//
// attsDic.Add(StrikethroughStyleAttributeName, stunderlineObject);
// --- end underline
}
// Text alignment
var alignment = CTTextAlignment.Left;
var alignmentSettings = new CTParagraphStyleSettings();
alignmentSettings.Alignment = alignment;
var paragraphStyle = new CTParagraphStyle(alignmentSettings);
ctAttributes.ParagraphStyle = paragraphStyle;
// end text alignment
NSMutableAttributedString atts =
new NSMutableAttributedString(text,ctAttributes.Dictionary);
return atts;
}
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:73,代码来源:CCLabelUtilities-CoreGraphics.cs
示例17: CreateColor
/** Returns a ccColor4F from a ccColor4B.
@since v0.99.1
*/
public static CCColor4F CreateColor(CCColor4B c)
{
CCColor4F c4 = new CCColor4F(c.R / 255.0f, c.G / 255.0f, c.B / 255.0f, c.A / 255.0f);
return c4;
}
开发者ID:CILP,项目名称:cocos2d-xna,代码行数:8,代码来源:ccTypes.cs
示例18: CCV2F_C4B_T2F
public CCV2F_C4B_T2F()
{
Vertices = new CCVertex2F();
Colors = new CCColor4B();
TexCoords = new CCTex2F();
}
开发者ID:CILP,项目名称:cocos2d-xna,代码行数:6,代码来源:ccTypes.cs
示例19: Lerp
public static CCColor4B Lerp(CCColor4B value1, CCColor4B value2, float amount)
{
CCColor4B color;
color.A = (byte)(value1.A + ((value2.A - value1.A) * amount));
color.R = (byte)(value1.R + ((value2.R - value1.R) * amount));
color.G = (byte)(value1.G + ((value2.G - value1.G) * amount));
color.B = (byte)(value1.B + ((value2.B - value1.B) * amount));
return color;
}
开发者ID:CILP,项目名称:cocos2d-xna,代码行数:11,代码来源:ccTypes.cs
示例20: DrawCubicBezier
/// <summary>
/// draws a cubic bezier path
/// @since v0.8
/// </summary>
public static void DrawCubicBezier(CCPoint origin, CCPoint control1, CCPoint control2, CCPoint destination, int segments, CCColor4B color)
{
var vertices = new VertexPositionColor[segments + 1];
float t = 0;
for (int i = 0; i < segments; ++i)
{
float x = CCSplineMath.CubicBezier(origin.X, control1.X, control2.X, destination.X, t);
float y = CCSplineMath.CubicBezier(origin.Y, control1.Y, control2.Y, destination.Y, t);
vertices[i] = new VertexPositionColor();
vertices[i].Position = new Vector3(x, y, 0);
vertices[i].Color = new Color(color.R, color.G, color.B, color.A);
t += 1.0f / segments;
}
vertices[segments] = new VertexPositionColor
{
Color = new Color(color.R, color.G, color.B, color.A),
Position = new Vector3(destination.X, destination.Y, 0)
};
BasicEffect basicEffect = CCDrawManager.PrimitiveEffect;
basicEffect.Projection = CCDrawManager.ProjectionMatrix;
basicEffect.View = CCDrawManager.ViewMatrix;
basicEffect.World = CCDrawManager.WorldMatrix;
foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
{
pass.Apply();
basicEffect.GraphicsDevice.DrawUserPrimitives(PrimitiveType.LineStrip, vertices, 0, segments);
}
}
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:37,代码来源:CCDrawingPrimitives.cs
注:本文中的Cocos2D.CCColor4B类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论