• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# CocosSharp.CCColor4B类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



CCColor4B类属于CocosSharp命名空间,在下文中一共展示了CCColor4B类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
        }
开发者ID:JoseManuelLopez,项目名称:cocos-sharp-samples,代码行数:45,代码来源:SpriteWithColor.cs


示例2: Background

 public Background(CCSize size, CCColor4B color)
 {
     Color = new CCColor3B(color);
     Opacity = color.A;
     AnchorPoint = CCPoint.AnchorMiddle;
     ContentSize = size;
 }
开发者ID:KerwinMa,项目名称:CocosSharp,代码行数:7,代码来源:RotateWorldMainLayer.cs


示例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;

        }
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:30,代码来源:SpriteWithColor.cs


示例4: AlignmentPanel

 public AlignmentPanel(CCSize size, CCColor4B color)
 {
     Color = new CCColor3B(color);
     Opacity = color.A;
     //AnchorPoint = CCPoint.AnchorMiddle;
     ContentSize = size;
 }
开发者ID:h7ing,项目名称:CocosSharp,代码行数:7,代码来源:LabelTTFTest.cs


示例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;
		}
开发者ID:KerwinMa,项目名称:CocosSharp,代码行数:59,代码来源:CCLabelUtilities-Gdi.cs


示例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;
 }
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:8,代码来源:Box2DDebug.cs


示例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);
        }
开发者ID:Nuckal777,项目名称:mapKnight,代码行数:10,代码来源:DebugDraw.cs


示例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 ();
 }
开发者ID:DriesMeerman,项目名称:fallball,代码行数:10,代码来源:Ball.cs


示例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();

        }
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:65,代码来源:StripeWithColor.cs


示例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;
			//}
		}
开发者ID:AnimaRobotics,项目名称:CocosSharp,代码行数:13,代码来源:CCLabel-CoreGraphics.cs


示例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);
        }
开发者ID:KevinHeyer,项目名称:CocosSharp,代码行数:13,代码来源:CCDrawingPrimitives.cs


示例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);
        }
开发者ID:xxy1991,项目名称:cozy,代码行数:16,代码来源:CozyColorSampleButton.cs


示例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;

        }
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:46,代码来源:DrawNodeBuffer.cs


示例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);
        }
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:44,代码来源:LineContainer.cs


示例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;
        }
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:22,代码来源:StripeWithColor.cs


示例16: CCColor3B

 public CCColor3B(CCColor4B color4B): this(color4B.R, color4B.G, color4B.B)
 {
 }
开发者ID:haithemaraissia,项目名称:CocosSharp,代码行数:3,代码来源:CCTypes.cs


示例17: CCV3F_C4B

 public CCV3F_C4B(CCPoint position, CCColor4B color)
 {
     this.Vertices = CCVertex3F.Zero;
     this.Vertices.X = position.X;
     this.Vertices.Y = position.Y;
     Colors = color;
 }
开发者ID:haithemaraissia,项目名称:CocosSharp,代码行数:7,代码来源:CCTypes.cs


示例18: CCV2F_C4B_T2F

 public CCV2F_C4B_T2F()
 {
     Vertices = new CCVertex2F();
     Colors = new CCColor4B();
     TexCoords = new CCTex2F();
 }
开发者ID:haithemaraissia,项目名称:CocosSharp,代码行数:6,代码来源:CCTypes.cs


示例19: CCPointSprite

 public CCPointSprite()
 {
     Position = new CCVertex2F();
     Color = new CCColor4B();
     Size = 0.0f;
 }
开发者ID:haithemaraissia,项目名称:CocosSharp,代码行数:6,代码来源:CCTypes.cs


示例20: CCColor4F

 public CCColor4F(CCColor4B color4B) : this(color4B.R / 255.0f, color4B.G / 255.0f, color4B.B / 255.0f, color4B.A / 255.0f)
 {
 }
开发者ID:haithemaraissia,项目名称:CocosSharp,代码行数:3,代码来源:CCTypes.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CocosSharp.CCEvent类代码示例发布时间:2022-05-24
下一篇:
C# CocosSharp.CCApplication类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap