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


C# Cocos2D.CCColor4F类代码示例

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


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

示例1: CCC3BFromCCC4F

        public static CCColor3B CCC3BFromCCC4F(CCColor4F floatColor)
        {
            CCColor3B color;
            color.R = CCColorByteFromFloat(floatColor.R);
            color.G = CCColorByteFromFloat(floatColor.G);
            color.B = CCColorByteFromFloat(floatColor.B);

            return color;
        }
开发者ID:rtabbara,项目名称:Cocos3D-XNA,代码行数:9,代码来源:LCC3ColorUtil.cs

示例2: doTest

        public override void doTest()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;
            CCParticleSystem particleSystem = (CCParticleSystem)GetChildByTag(PerformanceParticleTest.kTagParticleSystem);

            // duration
            particleSystem.Duration = -1;

            // gravity
            particleSystem.Gravity = new CCPoint(0, -90);

            // angle
            particleSystem.Angle = 90;
            particleSystem.AngleVar = 0;

            // radial
            particleSystem.RadialAccel = (0);
            particleSystem.RadialAccelVar = (0);

            // speed of particles
            particleSystem.Speed = (180);
            particleSystem.SpeedVar = (50);

            // emitter position
            particleSystem.Position = new CCPoint(s.Width / 2, 100);
            particleSystem.PosVar = new CCPoint(s.Width / 2, 0);

            // life of particles
            particleSystem.Life = 2.0f;
            particleSystem.LifeVar = 1;

            // emits per frame
            particleSystem.EmissionRate = particleSystem.TotalParticles / particleSystem.Life;

            // color of particles
            CCColor4F startColor = new CCColor4F { R = 0.5f, G = 0.5f, B = 0.5f, A = 1.0f };
            particleSystem.StartColor = startColor;

            CCColor4F startColorVar = new CCColor4F { R = 0.5f, G = 0.5f, B = 0.5f, A = 1.0f };
            particleSystem.StartColorVar = startColorVar;

            CCColor4F endColor = new CCColor4F { R = 0.1f, G = 0.1f, B = 0.1f, A = 0.2f };
            particleSystem.EndColor = endColor;

            CCColor4F endColorVar = new CCColor4F { R = 0.1f, G = 0.1f, B = 0.1f, A = 0.2f };
            particleSystem.EndColorVar = endColorVar;

            // size, in pixels
            particleSystem.EndSize = 32.0f;
            particleSystem.StartSize = 32.0f;
            particleSystem.EndSizeVar = 0;
            particleSystem.StartSizeVar = 0;

            // additive
            particleSystem.BlendAdditive = false;
        }
开发者ID:Karunp,项目名称:cocos2d-xna,代码行数:56,代码来源:ParticlePerformTest3.cs

示例3: CCC4FBlendAlpha

        public static CCColor4F CCC4FBlendAlpha(CCColor4F rgba)
        {
            CCColor4F result;
            result.R = MathHelper.Clamp(rgba.R * rgba.A, 0.0f, 1.0f);
            result.G = MathHelper.Clamp(rgba.G * rgba.A, 0.0f, 1.0f);
            result.B = MathHelper.Clamp(rgba.B * rgba.A, 0.0f, 1.0f);
            result.A = rgba.A;

            return result;
        }
开发者ID:rtabbara,项目名称:Cocos3D-XNA,代码行数:10,代码来源:LCC3ColorUtil.cs

示例4: DrawSegment

        /// <summary>
        /// Creates 18 vertices that create a segment between the two points with the given radius of rounding
        /// on the segment end. The color is used to draw the segment.
        /// </summary>
        /// <param name="from"></param>
        /// <param name="to"></param>
        /// <param name="radius"></param>
        /// <param name="color"></param>
        /// <returns>The starting vertex index of the segment.</returns>
        public virtual int DrawSegment(CCPoint from, CCPoint to, float radius, CCColor4F color)
        {
            var cl = new Color(color.R, color.G, color.B, color.A);

            var a = from;
            var b = to;

            var n = CCPoint.Normalize(CCPoint.Perp(a - b));
            var t = CCPoint.Perp(n);

            var nw = n * radius;
            var tw = t * radius;
            var v0 = b - (nw + tw);
            var v1 = b + (nw - tw);
            var v2 = b - nw;
            var v3 = b + nw;
            var v4 = a - nw;
            var v5 = a + nw;
            var v6 = a - (nw - tw);
            var v7 = a + (nw + tw);

            int returnIndex = m_pVertices.Count;
            m_pVertices.Add(new VertexPositionColor(v0, cl)); //__t(v2fneg(v2fadd(n, t)))
            m_pVertices.Add(new VertexPositionColor(v1, cl)); //__t(v2fsub(n, t))
            m_pVertices.Add(new VertexPositionColor(v2, cl)); //__t(v2fneg(n))}

            m_pVertices.Add(new VertexPositionColor(v3, cl)); //__t(n)
            m_pVertices.Add(new VertexPositionColor(v1, cl)); //__t(v2fsub(n, t))
            m_pVertices.Add(new VertexPositionColor(v2, cl)); //__t(v2fneg(n))

            m_pVertices.Add(new VertexPositionColor(v3, cl)); //__t(n)
            m_pVertices.Add(new VertexPositionColor(v4, cl)); //__t(v2fneg(n))
            m_pVertices.Add(new VertexPositionColor(v2, cl)); //__t(v2fneg(n))

            m_pVertices.Add(new VertexPositionColor(v3, cl)); //__t(n)
            m_pVertices.Add(new VertexPositionColor(v4, cl)); //__t(v2fneg(n))
            m_pVertices.Add(new VertexPositionColor(v5, cl)); //__t(n)

            m_pVertices.Add(new VertexPositionColor(v6, cl)); //__t(v2fsub(t, n))
            m_pVertices.Add(new VertexPositionColor(v4, cl)); //__t(v2fneg(n))
            m_pVertices.Add(new VertexPositionColor(v5, cl)); //__t(n)

            m_pVertices.Add(new VertexPositionColor(v6, cl)); //__t(v2fsub(t, n))
            m_pVertices.Add(new VertexPositionColor(v7, cl)); //__t(v2fadd(n, t))
            m_pVertices.Add(new VertexPositionColor(v5, cl)); //__t(n)

            m_bDirty = true;
            return (returnIndex);
        }
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:58,代码来源:CCDrawNode.cs

示例5: DrawDot

        /** draw a dot at a position, with a given radius and color */

        public void DrawDot(CCPoint pos, float radius, CCColor4F color)
        {
            var cl = new Color(color.R, color.G, color.B, color.A);

            var a = new VertexPositionColor(new Vector3(pos.X - radius, pos.Y - radius, 0), cl); //{-1.0, -1.0}
            var b = new VertexPositionColor(new Vector3(pos.X - radius, pos.Y + radius, 0), cl); //{-1.0,  1.0}
            var c = new VertexPositionColor(new Vector3(pos.X + radius, pos.Y + radius, 0), cl); //{ 1.0,  1.0}
            var d = new VertexPositionColor(new Vector3(pos.X + radius, pos.Y - radius, 0), cl); //{ 1.0, -1.0}

            m_pVertices.Add(a);
            m_pVertices.Add(b);
            m_pVertices.Add(c);

            m_pVertices.Add(a);
            m_pVertices.Add(c);
            m_pVertices.Add(d);

            m_bDirty = true;
        }
开发者ID:womandroid,项目名称:cocos2d-xna,代码行数:21,代码来源:CCDrawNode.cs

示例6: CCV2F_C4F_T2F

 public CCV2F_C4F_T2F()
 {
     Vertices = new CCVertex2F();
     Colors = new CCColor4F();
     TexCoords = new CCTex2F();
 }
开发者ID:CILP,项目名称:cocos2d-xna,代码行数:6,代码来源:ccTypes.cs

示例7: CCColor4F

 public static CCColor4F operator /(CCColor4F c, float amt)
 {
     CCColor4F nc = new CCColor4F(c.R / amt, c.G / amt, c.B / amt, c.A);
     return (nc);
 }
开发者ID:CILP,项目名称:cocos2d-xna,代码行数:5,代码来源:ccTypes.cs

示例8: OnEnter

        public override void OnEnter()
        {
            base.OnEnter();

            m_emitter = new CCParticleSystemQuad();
            m_emitter.InitWithTotalParticles(1000);
            //m_emitter.autorelease();

            m_background.AddChild(m_emitter, 10);
            ////m_emitter.release();

            CCSize s = CCDirector.SharedDirector.WinSize;

            // duration
            m_emitter.Duration = -1;

            // gravity
            m_emitter.Gravity = (new CCPoint(0, 0));

            // angle
            m_emitter.Angle = 0;
            m_emitter.AngleVar = 360;

            // radial
            m_emitter.RadialAccel = (70);
            m_emitter.RadialAccelVar = (10);

            // tagential
            m_emitter.TangentialAccel = (80);
            m_emitter.TangentialAccelVar = (0);

            // speed of particles
            m_emitter.Speed = (50);
            m_emitter.SpeedVar = (10);

            // emitter position
            m_emitter.Position = new CCPoint(s.Width / 2, s.Height / 2);
            m_emitter.PosVar = new CCPoint(0, 0);

            // life of particles
            m_emitter.Life = 2.0f;
            m_emitter.LifeVar = 0.3f;

            // emits per frame
            m_emitter.EmissionRate = m_emitter.TotalParticles / m_emitter.Life;

            // color of particles
            var startColor = new CCColor4F(0.5f, 0.5f, 0.5f, 1.0f);
            m_emitter.StartColor = startColor;

            var startColorVar = new CCColor4F(0.5f, 0.5f, 0.5f, 1.0f);
            m_emitter.StartColorVar = startColorVar;

            var endColor = new CCColor4F(0.1f, 0.1f, 0.1f, 0.2f);
            m_emitter.EndColor = endColor;

            var endColorVar = new CCColor4F(0.1f, 0.1f, 0.1f, 0.2f);
            m_emitter.EndColorVar = endColorVar;

            // size, in pixels
            m_emitter.StartSize = 1.0f;
            m_emitter.StartSizeVar = 1.0f;
            m_emitter.EndSize = 32.0f;
            m_emitter.EndSizeVar = 8.0f;

            // texture
            m_emitter.Texture = CCTextureCache.SharedTextureCache.AddImage(TestResource.s_fire);

            // additive
            m_emitter.BlendAdditive = false;

            setEmitterPosition();
        }
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:73,代码来源:ParticleTest.cs

示例9: Setup

        public override void Setup()
        {
            var s = CCDirector.SharedDirector.WinSize;

            CCClippingNode clipper = new CCClippingNode();
            clipper.Tag = kTagClipperNode;
            clipper.ContentSize = new CCSize(200, 200);
            clipper.AnchorPoint = new CCPoint(0.5f, 0.5f);
            clipper.Position = ContentSize.Center;
            clipper.RunAction(new CCRepeatForever(new CCRotateBy(1, 45)));
            AddChild(clipper);

            CCDrawNode stencil = new CCDrawNode();
            CCPoint[] rectangle =
                {
                    new CCPoint(0, 0),
                    new CCPoint(clipper.ContentSize.Width, 0),
                    new CCPoint(clipper.ContentSize.Width, clipper.ContentSize.Height),
                    new CCPoint(0, clipper.ContentSize.Height),
                };

            CCColor4F white = new CCColor4F(1, 1, 1, 1);
            stencil.DrawPolygon(rectangle, 4, white, 0, white);
            clipper.Stencil = stencil;

            CCSprite content = new CCSprite(TestResource.s_back2);
            content.Tag = kTagContentNode;
            content.AnchorPoint = new CCPoint(0.5f, 0.5f);
            content.Position = clipper.ContentSize.Center;
            clipper.AddChild(content);

            m_bScrolling = false;

            TouchEnabled = true;
        }
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:35,代码来源:ClippingNodeTestScene.cs

示例10: SetColor4FAtIndex

 public void SetColor4FAtIndex(CCColor4F color, uint index)
 {
     switch (_elementType)
     {
         case LCC3ElementType.Fixed:
         case LCC3ElementType.UnsignedByte:
             _vertices[(int)index] = LCC3ColorUtil.CCC4BFromCCC4F(color);
             break;
         default:
             _vertices[(int)index] = color;
             break;
     }
 }
开发者ID:rtabbara,项目名称:Cocos3D-XNA,代码行数:13,代码来源:LCC3VertexColors.cs

示例11: DrawRect

		public void DrawRect(CCRect rect, CCColor4F color, float borderWidth, CCColor4F borderColor)
		{
			float x1 = rect.MinX;
			float y1 = rect.MinY;
			float x2 = rect.MaxX;
			float y2 = rect.MaxY;
			CCPoint[] pt = new CCPoint[] { 
				new CCPoint(x1,y1), new CCPoint(x2,y1), new CCPoint(x2,y2), new CCPoint(x1,y2)
			};
			DrawPolygon(pt, 4, color, borderWidth, borderColor);
		}
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:11,代码来源:CCDrawNode.cs

示例12: DrawCircleOutline

        public void DrawCircleOutline(CCPoint center, float radius, float lineWidth, float angle, int segments, CCColor4B color)
        {
            float increment = MathHelper.Pi * 2.0f / segments;
            double theta = 0.0;

            CCPoint v1;
            CCPoint v2 = CCPoint.Zero;
            CCColor4F cf = new CCColor4F(color.R / 255f, color.G / 255f, color.B / 255f, color.A / 255f);

            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;
                DrawSegment(v1, v2, lineWidth, cf);
                theta += increment;
            }
        }
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:17,代码来源:CCDrawNode.cs

示例13: 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:womandroid,项目名称:cocos2d-xna,代码行数:19,代码来源:CCDrawNode.cs

示例14: DrawRect

 public void DrawRect(CCRect rect, CCColor4B color)
 {
     float x1 = rect.MinX;
     float y1 = rect.MinY;
     float x2 = rect.MaxX;
     float y2 = rect.MaxY;
     CCPoint[] pt = new CCPoint[] { 
         new CCPoint(x1,y1), new CCPoint(x2,y1), new CCPoint(x2,y2), new CCPoint(x1,y2)
     };
     CCColor4F cf = new CCColor4F(color.R/255f, color.G/255f, color.B/255f, color.A/255f);
     DrawPolygon(pt, 4, cf, 0, new CCColor4F(0f, 0f, 0f, 0f));
 }
开发者ID:womandroid,项目名称:cocos2d-xna,代码行数:12,代码来源:CCDrawNode.cs

示例15: DrawPolygon

        public void DrawPolygon(CCPoint[] verts, int count, CCColor4F fillColor, float borderWidth,
                                CCColor4F borderColor)
        {
            var extrude = new ExtrudeVerts[count];

            for (int i = 0; i < count; i++)
            {
                var v0 = verts[(i - 1 + count) % count];
                var v1 = verts[i];
                var v2 = verts[(i + 1) % count];

                var n1 = CCPoint.Normalize(CCPoint.Perp(v1 - v0));
                var n2 = CCPoint.Normalize(CCPoint.Perp(v2 - v1));

                var offset = (n1 + n2) * (1.0f / (CCPoint.Dot(n1, n2) + 1.0f));
                extrude[i] = new ExtrudeVerts() {offset = offset, n = n2};
            }

            bool outline = (fillColor.A > 0.0f && borderWidth > 0.0f);

            float inset = (!outline ? 0.5f : 0.0f);
            
            for (int i = 0; i < count - 2; i++)
            {
                var v0 = verts[0] - (extrude[0].offset * inset);
                var v1 = verts[i + 1] - (extrude[i + 1].offset * inset);
                var v2 = verts[i + 2] - (extrude[i + 2].offset * inset);

                m_pVertices.Add(new VertexPositionColor(v0, fillColor)); //__t(v2fzero)
                m_pVertices.Add(new VertexPositionColor(v1, fillColor)); //__t(v2fzero)
                m_pVertices.Add(new VertexPositionColor(v2, fillColor)); //__t(v2fzero)
            }

            for (int i = 0; i < count; i++)
            {
                int j = (i + 1) % count;
                var v0 = verts[i];
                var v1 = verts[j];

                var n0 = extrude[i].n;

                var offset0 = extrude[i].offset;
                var offset1 = extrude[j].offset;

                if (outline)
                {
                    var inner0 = (v0 - (offset0 * borderWidth));
                    var inner1 = (v1 - (offset1 * borderWidth));
                    var outer0 = (v0 + (offset0 * borderWidth));
                    var outer1 = (v1 + (offset1 * borderWidth));

                    m_pVertices.Add(new VertexPositionColor(inner0, borderColor)); //__t(v2fneg(n0))
                    m_pVertices.Add(new VertexPositionColor(inner1, borderColor)); //__t(v2fneg(n0))
                    m_pVertices.Add(new VertexPositionColor(outer1, borderColor)); //__t(n0)

                    m_pVertices.Add(new VertexPositionColor(inner0, borderColor)); //__t(v2fneg(n0))
                    m_pVertices.Add(new VertexPositionColor(outer0, borderColor)); //__t(n0)
                    m_pVertices.Add(new VertexPositionColor(outer1, borderColor)); //__t(n0)
                }
                else
                {
                    var inner0 = (v0 - (offset0 * 0.5f));
                    var inner1 = (v1 - (offset1 * 0.5f));
                    var outer0 = (v0 + (offset0 * 0.5f));
                    var outer1 = (v1 + (offset1 * 0.5f));

                    m_pVertices.Add(new VertexPositionColor(inner0, fillColor)); //__t(v2fzero)
                    m_pVertices.Add(new VertexPositionColor(inner1, fillColor)); //__t(v2fzero)
                    m_pVertices.Add(new VertexPositionColor(outer1, fillColor)); //__t(n0)

                    m_pVertices.Add(new VertexPositionColor(inner0, fillColor)); //__t(v2fzero)
                    m_pVertices.Add(new VertexPositionColor(outer0, fillColor)); //__t(n0)
                    m_pVertices.Add(new VertexPositionColor(outer1, fillColor)); //__t(n0)
                }
            }

            m_bDirty = true;
        }
开发者ID:womandroid,项目名称:cocos2d-xna,代码行数:78,代码来源:CCDrawNode.cs


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