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


C# Cocos2D.CCColor4B类代码示例

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


CCColor4B类属于Cocos2D命名空间,在下文中一共展示了CCColor4B类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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