Esempio n. 1
0
 public ccColor4B(ccColor4B copy)
 {
     this.r = copy.r;
     this.g = copy.g;
     this.b = copy.b;
     this.a = copy.a;
 }
Esempio n. 2
0
 public ccColor4B(ccColor4B copy)
 {
     r = copy.r;
     g = copy.g;
     b = copy.b;
     a = copy.a;
 }
Esempio n. 3
0
        protected void updateColor()
        {
            byte      opacity    = this.m_pSprite.Opacity;
            ccColor3B color      = this.m_pSprite.Color;
            ccColor4B _ccColor4B = new ccColor4B()
            {
                r = color.r,
                g = color.g,
                b = color.b,
                a = opacity
            };
            ccColor4B _ccColor4B1 = _ccColor4B;

            if (this.m_pSprite.Texture.HasPremultipliedAlpha)
            {
                ccColor4B _ccColor4B2 = _ccColor4B1;
                _ccColor4B2.r = (byte)(_ccColor4B2.r * (byte)(opacity / 255));
                ccColor4B _ccColor4B3 = _ccColor4B1;
                _ccColor4B3.g = (byte)(_ccColor4B3.g * (byte)(opacity / 255));
                ccColor4B _ccColor4B4 = _ccColor4B1;
                _ccColor4B4.b = (byte)(_ccColor4B4.b * (byte)(opacity / 255));
            }
            if (this.m_pVertexData != null)
            {
                for (int i = 0; i < this.m_nVertexDataCount; i++)
                {
                    this.m_pVertexData[i].colors = _ccColor4B1;
                }
            }
        }
Esempio n. 4
0
        public virtual bool initWithColor(ccColor4B color)
        {
            CCSize winSize = CCDirector.sharedDirector().getWinSize();

            this.initWithColorWidthHeight(color, winSize.width, winSize.height);
            return(true);
        }
Esempio n. 5
0
        /// <summary>
        ///  initializes a CCLayer with color, width and height in Points
        /// </summary>
        public virtual bool initWithColorWidthHeight(ccColor4B color, float width, float height)
        {
            // default blend function
            m_tBlendFunc.src = 1;
            m_tBlendFunc.dst = 0x0303;

            m_tColor.r = color.r;
            m_tColor.g = color.g;
            m_tColor.b = color.b;
            m_cOpacity = color.a;
            for (int i = 0; i < m_pSquareVertices.Length; i++)
            {
                m_pSquareVertices[i]   = new ccVertex2F();
                m_pSquareVertices[i].x = 0.0f;
                m_pSquareVertices[i].y = 0.0f;

                vertices[i] = new VertexPositionColor();
            }

            indexes[0] = 0;
            indexes[0] = 1;
            indexes[0] = 2;
            indexes[0] = 2;
            indexes[0] = 1;
            indexes[0] = 3;

            this.updateColor();
            this.contentSize = new CCSize(width, height);
            return(true);
        }
Esempio n. 6
0
        /// <summary>
        /// initializes a CCLayer with color. Width and height are the window size.
        /// </summary>
        public virtual bool initWithColor(ccColor4B color)
        {
            CCSize s = Director.SharedDirector.DesignSize;

            this.initWithColorWidthHeight(color, s.Width, s.Height);
            return(true);
        }
Esempio n. 7
0
        public virtual bool init()
        {
            this.m_bDirty = this.m_bRecursiveDirty = false;
            this.useSelfRender();
            this.m_bOpacityModifyRGB        = true;
            this.m_nOpacity                 = 0xff;
            this.m_sColor                   = new ccColor3B(0xff, 0xff, 0xff);
            this.m_sColorUnmodified         = new ccColor3B(0xff, 0xff, 0xff);
            this.m_sBlendFunc               = new ccBlendFunc();
            this.m_sBlendFunc.src           = ccMacros.CC_BLEND_SRC;
            this.m_sBlendFunc.dst           = ccMacros.CC_BLEND_DST;
            this.Texture                    = null;
            this.m_sQuad                    = new ccV3F_C4B_T2F_Quad();
            this.m_bFlipX                   = this.m_bFlipY = false;
            this.anchorPoint                = CCPointExtension.ccp(0.5f, 0.5f);
            this.m_obOffsetPositionInPixels = new CCPoint();
            this.m_eHonorParentTransform    = ccHonorParentTransform.CC_HONOR_PARENT_TRANSFORM_ALL;
            this.m_bHasChildren             = false;
            ccColor4B colorb = new ccColor4B(0xff, 0xff, 0xff, 0xff);

            this.m_sQuad.bl.colors = colorb;
            this.m_sQuad.br.colors = colorb;
            this.m_sQuad.tl.colors = colorb;
            this.m_sQuad.tr.colors = colorb;
            this.setTextureRectInPixels(new CCRect(), false, new CCSize());
            return(true);
        }
Esempio n. 8
0
 public virtual bool initWithColorWidthHeight(ccColor4B color, float width, float height)
 {
     this.m_tBlendFunc.src = 1;
     this.m_tBlendFunc.dst = 771;
     this.m_tColor.r       = color.r;
     this.m_tColor.g       = color.g;
     this.m_tColor.b       = color.b;
     this.m_cOpacity       = color.a;
     for (int i = 0; i < (int)this.m_pSquareVertices.Length; i++)
     {
         this.m_pSquareVertices[i]   = new ccVertex2F();
         this.m_pSquareVertices[i].x = 0f;
         this.m_pSquareVertices[i].y = 0f;
         this.vertices[i]            = new VertexPositionColor();
     }
     this.indexes[0] = 0;
     this.indexes[0] = 1;
     this.indexes[0] = 2;
     this.indexes[0] = 2;
     this.indexes[0] = 1;
     this.indexes[0] = 3;
     this.updateColor();
     this.contentSize = new CCSize(width, height);
     return(true);
 }
        public override void updateQuadWithParticle(CCParticle particle, CCPoint newPosition)
        {
            this.m_pVertices[base.m_uParticleIdx].pos  = ccTypes.vertex2(newPosition.x, newPosition.y);
            this.m_pVertices[base.m_uParticleIdx].size = particle.size;
            ccColor4B colorb = new ccColor4B((byte)(particle.color.r * 255f), (byte)(particle.color.g * 255f), (byte)(particle.color.b * 255f), (byte)(particle.color.a * 255f));

            this.m_pVertices[base.m_uParticleIdx].color = colorb;
        }
        public override bool init()
        {
            // always call "super" init
            // Apple recommends to re-assign "self" with the "super" return value
            if (base.init())
            {
                isTouchEnabled = true;
                // ask director the the window size
                CCSize size = CCDirector.sharedDirector().getWinSize();
                CCLayerColor layer;
                CCUserDefault.sharedUserDefault().setBoolForKey("bool", true);
                for (int i = 0; i < 5; i++)
                {
                    ccColor4B c = new ccColor4B((byte)(i * 20), (byte)(i * 20), (byte)(i * 20), 255);
                    CCUserDefault.sharedUserDefault().setStringForKey("i" + i, c.ToString());
                }
                CCUserDefault.sharedUserDefault().flush();
                bool testValue = CCUserDefault.sharedUserDefault().getBoolForKey("bool", false);
                if(!testValue) {
                    CCLog.Log("CCUserDefault: Test failed b/c the 'bool' value was not true when it was expected.");
                }
                for (int i = 0; i < 5; i++)
                {
                    string cstr = CCUserDefault.sharedUserDefault().getStringForKey("i" + i, null);
                    if (cstr == null)
                    {
                        CCLog.Log("CCUserDefault: The color for iteration #" + i + " is null.");
                        continue;
                    }
                    ccColor4B c = new ccColor4B((byte)(i * 20), (byte)(i * 20), (byte)(i * 20), 255);
                    layer = CCLayerColor.layerWithColor(c);
                    layer.contentSize = new CCSize(i * 100, i * 100);
                    layer.position = new CCPoint(size.width / 2, size.height / 2);
                    layer.anchorPoint = new CCPoint(0.5f, 0.5f);
                    layer.isRelativeAnchorPoint = true;
                    addChild(layer, -1 - i);

                }

                // create and initialize a Label
                CCLabelTTF label = CCLabelTTF.labelWithString("ccUserDefault Test", "Arial", 14);
                CCMenuItem item1 = CCMenuItemFont.itemFromString("restart", this, restart);

                CCMenu menu = CCMenu.menuWithItems(item1);
                menu.alignItemsVertically();
                menu.position = new CCPoint(size.width / 2, 100);
                addChild(menu);

                // position the label on the center of the screen
                label.position = new CCPoint(size.width / 2, size.height / 2);

                // add the label as a child to this Layer
                addChild(label);
                return true;
            }
            return false;
        }
Esempio n. 11
0
        protected override void updateColor()
        {
            base.updateColor();
            float single = CCPointExtension.ccpLength(this.m_AlongVector);

            if (single == 0f)
            {
                return;
            }
            double  num     = Math.Sqrt(2);
            CCPoint cCPoint = new CCPoint(this.m_AlongVector.x / single, this.m_AlongVector.y / single);

            if (this.m_bCompressedInterpolation)
            {
                float single1 = 1f / (Math.Abs(cCPoint.x) + Math.Abs(cCPoint.y));
                cCPoint = CCPointExtension.ccpMult(cCPoint, single1 * (float)num);
            }
            float     mCOpacity  = (float)this.m_cOpacity / 255f;
            ccColor4B _ccColor4B = new ccColor4B()
            {
                r = this.m_tColor.r,
                g = this.m_tColor.g,
                b = this.m_tColor.b,
                a = (byte)((float)this.m_cStartOpacity * mCOpacity)
            };
            ccColor4B _ccColor4B1 = _ccColor4B;
            ccColor4B _ccColor4B2 = new ccColor4B()
            {
                r = this.m_endColor.r,
                g = this.m_endColor.g,
                b = this.m_endColor.b,
                a = (byte)((float)this.m_cEndOpacity * mCOpacity)
            };
            ccColor4B _ccColor4B3 = _ccColor4B2;

            this.m_pSquareColors[0].r = (byte)((double)_ccColor4B3.r + (double)(_ccColor4B1.r - _ccColor4B3.r) * ((num + (double)cCPoint.x + (double)cCPoint.y) / (2 * num)));
            this.m_pSquareColors[0].g = (byte)((double)_ccColor4B3.g + (double)(_ccColor4B1.g - _ccColor4B3.g) * ((num + (double)cCPoint.x + (double)cCPoint.y) / (2 * num)));
            this.m_pSquareColors[0].b = (byte)((double)_ccColor4B3.b + (double)(_ccColor4B1.b - _ccColor4B3.b) * ((num + (double)cCPoint.x + (double)cCPoint.y) / (2 * num)));
            this.m_pSquareColors[0].a = (byte)((double)_ccColor4B3.a + (double)(_ccColor4B1.a - _ccColor4B3.a) * ((num + (double)cCPoint.x + (double)cCPoint.y) / (2 * num)));
            this.m_pSquareColors[1].r = (byte)((double)_ccColor4B3.r + (double)(_ccColor4B1.r - _ccColor4B3.r) * ((num - (double)cCPoint.x + (double)cCPoint.y) / (2 * num)));
            this.m_pSquareColors[1].g = (byte)((double)_ccColor4B3.g + (double)(_ccColor4B1.g - _ccColor4B3.g) * ((num - (double)cCPoint.x + (double)cCPoint.y) / (2 * num)));
            this.m_pSquareColors[1].b = (byte)((double)_ccColor4B3.b + (double)(_ccColor4B1.b - _ccColor4B3.b) * ((num - (double)cCPoint.x + (double)cCPoint.y) / (2 * num)));
            this.m_pSquareColors[1].a = (byte)((double)_ccColor4B3.a + (double)(_ccColor4B1.a - _ccColor4B3.a) * ((num - (double)cCPoint.x + (double)cCPoint.y) / (2 * num)));
            this.m_pSquareColors[2].r = (byte)((double)_ccColor4B3.r + (double)(_ccColor4B1.r - _ccColor4B3.r) * ((num + (double)cCPoint.x - (double)cCPoint.y) / (2 * num)));
            this.m_pSquareColors[2].g = (byte)((double)_ccColor4B3.g + (double)(_ccColor4B1.g - _ccColor4B3.g) * ((num + (double)cCPoint.x - (double)cCPoint.y) / (2 * num)));
            this.m_pSquareColors[2].b = (byte)((double)_ccColor4B3.b + (double)(_ccColor4B1.b - _ccColor4B3.b) * ((num + (double)cCPoint.x - (double)cCPoint.y) / (2 * num)));
            this.m_pSquareColors[2].a = (byte)((double)_ccColor4B3.a + (double)(_ccColor4B1.a - _ccColor4B3.a) * ((num + (double)cCPoint.x - (double)cCPoint.y) / (2 * num)));
            this.m_pSquareColors[3].r = (byte)((double)_ccColor4B3.r + (double)(_ccColor4B1.r - _ccColor4B3.r) * ((num - (double)cCPoint.x - (double)cCPoint.y) / (2 * num)));
            this.m_pSquareColors[3].g = (byte)((double)_ccColor4B3.g + (double)(_ccColor4B1.g - _ccColor4B3.g) * ((num - (double)cCPoint.x - (double)cCPoint.y) / (2 * num)));
            this.m_pSquareColors[3].b = (byte)((double)_ccColor4B3.b + (double)(_ccColor4B1.b - _ccColor4B3.b) * ((num - (double)cCPoint.x - (double)cCPoint.y) / (2 * num)));
            this.m_pSquareColors[3].a = (byte)((double)_ccColor4B3.a + (double)(_ccColor4B1.a - _ccColor4B3.a) * ((num - (double)cCPoint.x - (double)cCPoint.y) / (2 * num)));
            this.vertices[0].Color    = new Microsoft.Xna.Framework.Color((int)this.m_pSquareColors[0].r, (int)this.m_pSquareColors[0].g, (int)this.m_pSquareColors[0].b, (int)this.m_pSquareColors[0].a);
            this.vertices[1].Color    = new Microsoft.Xna.Framework.Color((int)this.m_pSquareColors[1].r, (int)this.m_pSquareColors[1].g, (int)this.m_pSquareColors[1].b, (int)this.m_pSquareColors[1].a);
            this.vertices[2].Color    = new Microsoft.Xna.Framework.Color((int)this.m_pSquareColors[2].r, (int)this.m_pSquareColors[2].g, (int)this.m_pSquareColors[2].b, (int)this.m_pSquareColors[2].a);
            this.vertices[3].Color    = new Microsoft.Xna.Framework.Color((int)this.m_pSquareColors[3].r, (int)this.m_pSquareColors[3].g, (int)this.m_pSquareColors[3].b, (int)this.m_pSquareColors[3].a);
        }
        public override void updateQuadWithParticle(CCParticle particle, CCPoint newPosition)
        {
            // place vertices and colos in array
            m_pVertices[m_uParticleIdx].pos  = ccTypes.vertex2(newPosition.x, newPosition.y);
            m_pVertices[m_uParticleIdx].size = particle.size;
            ccColor4B color = new ccColor4B((Byte)(particle.color.r * 255), (Byte)(particle.color.g * 255), (Byte)(particle.color.b * 255),
                                            (Byte)(particle.color.a * 255));

            m_pVertices[m_uParticleIdx].color = color;
        }
Esempio n. 13
0
        /// <summary>
        /// Creates a full-screen CCLayer with a gradient between start and end in the direction of v. 
        /// </summary>
        public static CCLayerGradient layerWithColor(ccColor4B start, ccColor4B end, CCPoint v)
        {
            CCLayerGradient pLayer = new CCLayerGradient();
            if (pLayer.initWithColor(start, end, v))
            {
                return pLayer;
            }

            return null;
        }
Esempio n. 14
0
        public static CCLayerColor layerWithColor(ccColor4B color)
        {
            CCLayerColor cCLayerColor = new CCLayerColor();

            if (cCLayerColor.initWithColor(color))
            {
                return(cCLayerColor);
            }
            return(null);
        }
Esempio n. 15
0
        public static CCLayerColor layerWithColorWidthHeight(ccColor4B color, float width, float height)
        {
            CCLayerColor cCLayerColor = new CCLayerColor();

            if (cCLayerColor.initWithColorWidthHeight(color, width, height))
            {
                return(cCLayerColor);
            }
            return(null);
        }
Esempio n. 16
0
        public static CCLayerGradient layerWithColor(ccColor4B start, ccColor4B end, CCPoint v)
        {
            CCLayerGradient cCLayerGradient = new CCLayerGradient();

            if (cCLayerGradient.initWithColor(start, end, v))
            {
                return(cCLayerGradient);
            }
            return(null);
        }
Esempio n. 17
0
        public void tintWithColor(ccColor3B colors)
        {
            Color = colors;

            for (int i = 0; i < m_uNuPoints * 2; i++)
            {
                m_pColor[i] = new ccColor4B(colors);
                //        *((ccColor3B*) (m_pColorPointer+i*4)) = colors;
            }
        }
Esempio n. 18
0
        public override void updateAtlasValues()
        {
            char[]      charArray  = this.m_sString.ToCharArray();
            CCTexture2D texture    = this.m_pTextureAtlas.Texture;
            float       pixelsWide = (float)texture.PixelsWide;
            float       pixelsHigh = (float)texture.PixelsHigh;

            for (int i = 0; i < this.m_sString.Length; i++)
            {
                ccV3F_C4B_T2F_Quad ccV3FC4BT2FQuad = new ccV3F_C4B_T2F_Quad();
                char  mCMapStartChar = (char)(charArray[i] - this.m_cMapStartChar);
                float mUItemsPerRow  = (float)(mCMapStartChar % (char)this.m_uItemsPerRow);
                float single         = (float)(mCMapStartChar / (char)this.m_uItemsPerRow);
                float mUItemWidth    = mUItemsPerRow * (float)this.m_uItemWidth / pixelsWide;
                float mUItemWidth1   = mUItemWidth + (float)this.m_uItemWidth / pixelsWide;
                float mUItemHeight   = single * (float)this.m_uItemHeight / pixelsHigh;
                float mUItemHeight1  = mUItemHeight + (float)this.m_uItemHeight / pixelsHigh;
                ccV3FC4BT2FQuad.tl.texCoords.u = mUItemWidth;
                ccV3FC4BT2FQuad.tl.texCoords.v = mUItemHeight;
                ccV3FC4BT2FQuad.tr.texCoords.u = mUItemWidth1;
                ccV3FC4BT2FQuad.tr.texCoords.v = mUItemHeight;
                ccV3FC4BT2FQuad.bl.texCoords.u = mUItemWidth;
                ccV3FC4BT2FQuad.bl.texCoords.v = mUItemHeight1;
                ccV3FC4BT2FQuad.br.texCoords.u = mUItemWidth1;
                ccV3FC4BT2FQuad.br.texCoords.v = mUItemHeight1;
                ccV3F_C4B_T2F ccV3FC4BT2F  = ccV3FC4BT2FQuad.tl;
                ccV3F_C4B_T2F ccV3FC4BT2F1 = ccV3FC4BT2FQuad.tr;
                ccV3F_C4B_T2F ccV3FC4BT2F2 = ccV3FC4BT2FQuad.bl;
                ccV3F_C4B_T2F ccV3FC4BT2F3 = ccV3FC4BT2FQuad.br;
                ccColor4B     _ccColor4B   = new ccColor4B(this.m_tColor.r, this.m_tColor.g, this.m_tColor.b, this.m_cOpacity);
                ccColor4B     _ccColor4B1  = _ccColor4B;
                ccV3FC4BT2F3.colors = _ccColor4B;
                ccColor4B _ccColor4B2 = _ccColor4B1;
                ccColor4B _ccColor4B3 = _ccColor4B2;
                ccV3FC4BT2F2.colors = _ccColor4B2;
                ccColor4B _ccColor4B4 = _ccColor4B3;
                ccColor4B _ccColor4B5 = _ccColor4B4;
                ccV3FC4BT2F1.colors           = _ccColor4B4;
                ccV3FC4BT2F.colors            = _ccColor4B5;
                ccV3FC4BT2FQuad.bl.vertices.x = (float)(i * this.m_uItemWidth);
                ccV3FC4BT2FQuad.bl.vertices.y = 0f;
                ccV3FC4BT2FQuad.bl.vertices.z = 0f;
                ccV3FC4BT2FQuad.br.vertices.x = (float)(i * this.m_uItemWidth + this.m_uItemWidth);
                ccV3FC4BT2FQuad.br.vertices.y = 0f;
                ccV3FC4BT2FQuad.br.vertices.z = 0f;
                ccV3FC4BT2FQuad.tl.vertices.x = (float)(i * this.m_uItemWidth);
                ccV3FC4BT2FQuad.tl.vertices.y = (float)this.m_uItemHeight;
                ccV3FC4BT2FQuad.tl.vertices.z = 0f;
                ccV3FC4BT2FQuad.tr.vertices.x = (float)(i * this.m_uItemWidth + this.m_uItemWidth);
                ccV3FC4BT2FQuad.tr.vertices.y = (float)this.m_uItemHeight;
                ccV3FC4BT2FQuad.tr.vertices.z = 0f;
                this.m_pTextureAtlas.updateQuad(ccV3FC4BT2FQuad, i);
            }
        }
Esempio n. 19
0
        /// <summary>
        /// Creates a full-screen CCLayer with a gradient between start and end.
        /// </summary>
        public static CCLayerGradient layerWithColor(ccColor4B start, ccColor4B end)
        {
            CCLayerGradient pLayer = new CCLayerGradient();

            if (pLayer.initWithColor(start, end))
            {
                return(pLayer);
            }

            return(null);
        }
 /// <summary>
 /// initializes the transition with a duration and with an RGB color
 /// </summary>
 public virtual bool initWithDuration(float duration, CCScene scene, ccColor3B color)
 {
     if (base.initWithDuration(duration, scene))
     {
         m_tColor   = new ccColor4B();
         m_tColor.r = color.r;
         m_tColor.g = color.g;
         m_tColor.b = color.b;
         m_tColor.a = 0;
     }
     return(true);
 }
 /// <summary>
 /// initializes the transition with a duration and with an RGB color 
 /// </summary>
 public virtual bool initWithDuration(float duration, CCScene scene, ccColor3B color)
 {
     if (base.initWithDuration(duration, scene))
     {
         m_tColor = new ccColor4B();
         m_tColor.r = color.r;
         m_tColor.g = color.g;
         m_tColor.b = color.b;
         m_tColor.a = 0;
     }
     return true;
 }
Esempio n. 22
0
        public virtual bool init()
        {
            m_bDirty = m_bRecursiveDirty = false;

            // by default use "Self Render".
            // if the sprite is added to an batchnode, then it will automatically switch to "SpriteSheet Render"
            useSelfRender();

            m_bOpacityModifyRGB = true;
            m_nOpacity          = 255;
            m_sColor            = new ccColor3B(255, 255, 255);
            m_sColorUnmodified  = new ccColor3B(255, 255, 255);

            m_sBlendFunc     = new ccBlendFunc();
            m_sBlendFunc.src = ccMacros.CC_BLEND_SRC;
            m_sBlendFunc.dst = ccMacros.CC_BLEND_DST;


            // update texture (calls updateBlendFunc)
            Texture = null;

            // clean the Quad
            m_sQuad = new ccV3F_C4B_T2F_Quad();

            m_bFlipX = m_bFlipY = false;

            // default transform anchor: center
            anchorPoint = (CCPointExtension.ccp(0.5f, 0.5f));

            // zwoptex default values
            m_obOffsetPositionInPixels = new CCPoint();

            m_eHonorParentTransform = ccHonorParentTransform.CC_HONOR_PARENT_TRANSFORM_ALL;
            m_bHasChildren          = false;

            // Atlas: Color
            ccColor4B tmpColor = new ccColor4B(255, 255, 255, 255);

            m_sQuad.bl.colors = tmpColor;
            m_sQuad.br.colors = tmpColor;
            m_sQuad.tl.colors = tmpColor;
            m_sQuad.tr.colors = tmpColor;

            // Atlas: Vertex

            // updated in "useSelfRender"

            // Atlas: TexCoords

            setTextureRectInPixels(new CCRect(), false, new CCSize());

            return(true);
        }
Esempio n. 23
0
        protected virtual void updateColor()
        {
            for (int i = 0; i < 4; i++)
            {
                m_pSquareColors[i]   = new ccColor4B();
                m_pSquareColors[i].r = m_tColor.r;
                m_pSquareColors[i].g = m_tColor.g;
                m_pSquareColors[i].b = m_tColor.b;
                m_pSquareColors[i].a = m_cOpacity;

                vertices[i].Color = new Microsoft.Xna.Framework.Color(m_tColor.r, m_tColor.g, m_tColor.b, m_cOpacity);
            }
        }
        public override void updateQuadWithParticle(CCParticle particle, CCPoint newPosition)
        {
            ccV2F_C4B_T2F_Quad quad   = this.m_pQuads[base.m_uParticleIdx];
            ccColor4B          colorb = new ccColor4B((byte)(particle.color.r * 255f), (byte)(particle.color.g * 255f), (byte)(particle.color.b * 255f), (byte)(particle.color.a * 255f));

            quad.bl.colors = colorb;
            quad.br.colors = colorb;
            quad.tl.colors = colorb;
            quad.tr.colors = colorb;
            float num = particle.size / 2f;

            if (particle.rotation != 0f)
            {
                float num2  = -num;
                float num3  = -num;
                float num4  = num;
                float num5  = num;
                float x     = newPosition.x;
                float y     = newPosition.y;
                float num8  = -ccMacros.CC_DEGREES_TO_RADIANS(particle.rotation);
                float num9  = (float)Math.Cos((double)num8);
                float num10 = (float)Math.Sin((double)num8);
                float num11 = ((num2 * num9) - (num3 * num10)) + x;
                float num12 = ((num2 * num10) + (num3 * num9)) + y;
                float num13 = ((num4 * num9) - (num3 * num10)) + x;
                float num14 = ((num4 * num10) + (num3 * num9)) + y;
                float num15 = ((num4 * num9) - (num5 * num10)) + x;
                float num16 = ((num4 * num10) + (num5 * num9)) + y;
                float num17 = ((num2 * num9) - (num5 * num10)) + x;
                float num18 = ((num2 * num10) + (num5 * num9)) + y;
                quad.bl.vertices.x = num11;
                quad.bl.vertices.y = num12;
                quad.br.vertices.x = num13;
                quad.br.vertices.y = num14;
                quad.tl.vertices.x = num17;
                quad.tl.vertices.y = num18;
                quad.tr.vertices.x = num15;
                quad.tr.vertices.y = num16;
            }
            else
            {
                quad.bl.vertices.x = newPosition.x - num;
                quad.bl.vertices.y = newPosition.y - num;
                quad.br.vertices.x = newPosition.x + num;
                quad.br.vertices.y = newPosition.y - num;
                quad.tl.vertices.x = newPosition.x - num;
                quad.tl.vertices.y = newPosition.y + num;
                quad.tr.vertices.x = newPosition.x + num;
                quad.tr.vertices.y = newPosition.y + num;
            }
        }
Esempio n. 25
0
 public virtual bool initWithColor(ccColor4B start, ccColor4B end, CCPoint v)
 {
     this.m_endColor = new ccColor3B()
     {
         r = end.r,
         g = end.g,
         b = end.b
     };
     this.m_cEndOpacity              = end.a;
     this.m_cStartOpacity            = start.a;
     this.m_AlongVector              = v;
     this.m_bCompressedInterpolation = true;
     return(base.initWithColor(new ccColor4B(start.r, start.g, start.b, 255)));
 }
Esempio n. 26
0
 public virtual bool initWithDuration(float duration, CCScene scene, ccColor3B color)
 {
     if (base.initWithDuration(duration, scene))
     {
         this.m_tColor = new ccColor4B()
         {
             r = color.r,
             g = color.g,
             b = color.b,
             a = 0
         };
     }
     return(true);
 }
Esempio n. 27
0
        public override void onEnter()
        {
            base.onEnter();
            ccColor4B       _ccColor4B = new ccColor4B(0, 0, 0, 0);
            CCSize          winSize    = CCDirector.sharedDirector().getWinSize();
            CCLayer         cCLayer    = new CCLayer();
            CCRenderTexture cCPoint    = CCRenderTexture.renderTextureWithWidthAndHeight((int)winSize.width, (int)winSize.height);

            if (cCPoint == null)
            {
                return;
            }
            cCPoint.Sprite.anchorPoint = new CCPoint(0.5f, 0.5f);
            cCPoint.position           = new CCPoint(winSize.width / 2f, winSize.height / 2f);
            cCPoint.anchorPoint        = new CCPoint(0.5f, 0.5f);
            cCPoint.begin();
            this.m_pInScene.visit();
            cCPoint.end();
            CCRenderTexture cCRenderTexture = CCRenderTexture.renderTextureWithWidthAndHeight((int)winSize.width, (int)winSize.height);

            cCRenderTexture.Sprite.anchorPoint = new CCPoint(0.5f, 0.5f);
            cCRenderTexture.position           = new CCPoint(winSize.width / 2f, winSize.height / 2f);
            cCRenderTexture.anchorPoint        = new CCPoint(0.5f, 0.5f);
            cCRenderTexture.begin();
            this.m_pOutScene.visit();
            cCRenderTexture.end();
            ccBlendFunc _ccBlendFunc  = new ccBlendFunc(1, 1);
            ccBlendFunc _ccBlendFunc1 = new ccBlendFunc(770, 771);

            cCPoint.Sprite.BlendFunc         = _ccBlendFunc;
            cCRenderTexture.Sprite.BlendFunc = _ccBlendFunc1;
            cCLayer.addChild(cCPoint);
            cCLayer.addChild(cCRenderTexture);
            cCPoint.Sprite.Opacity         = 255;
            cCRenderTexture.Sprite.Opacity = 255;
            CCFiniteTimeAction[] cCFiniteTimeActionArray = new CCFiniteTimeAction[] { CCFadeTo.actionWithDuration(this.m_fDuration, 0), CCCallFunc.actionWithTarget(this, new SEL_CallFunc(this.hideOutShowIn)), CCCallFunc.actionWithTarget(this, new SEL_CallFunc(this.finish)) };
            CCAction             cCAction = CCSequence.actions(cCFiniteTimeActionArray);

            cCRenderTexture.Sprite.runAction(cCAction);
            this.addChild(cCLayer, 2, 2147483647);
        }
        /// <summary>
        /// draws a circle given the center, radius and number of segments.
        /// </summary>
        public static void ccDrawCircle(CCPoint center, float radius, float angle, int segments, bool drawLineToCenter, ccColor4B color)
        {
            int additionalSegment = 1;
            if (drawLineToCenter)
            {
                ++additionalSegment;
            }

            CCApplication app = CCApplication.sharedApplication();
            float factor = CCDirector.sharedDirector().ContentScaleFactor;
            float coef = 2.0f * (float)(Math.PI) / segments;

            VertexPositionColor[] vertices = new VertexPositionColor[2 * (segments + 2)]; //	float *vertices = (float *)malloc( sizeof(float)*2*(segs+2));

            //memset(vertices, 0, sizeof(float) * 2 * (segs + 2));

            for (int i = 0; i <= segments; i++)
            {
                float rads = i * coef;
                float j = radius * (float)Math.Cos(rads + angle) + center.x;
                float k = radius * (float)Math.Sin(rads + angle) + center.y;

                vertices[i] = new VertexPositionColor();
                vertices[i].Position = new Vector3(j * factor, k * factor, 0);
                vertices[i].Color = new Color(color.r, color.g, color.b, color.a);
            }

            //vertices[(segments + 1) * 2] = new VertexPositionColor();
            //vertices[(segments + 1) * 2].Position = new Vector3(center.x * factor, center.y * factor, 0);

            app.basicEffect.TextureEnabled = false;
            app.basicEffect.VertexColorEnabled = true;
            foreach (var pass in app.basicEffect.CurrentTechnique.Passes)
            {
                pass.Apply();

                app.GraphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.LineStrip, vertices, 0, segments);
            }
        }
Esempio n. 29
0
        protected void updateColor()
        {
            byte      op  = m_pSprite.Opacity;
            ccColor3B c3b = m_pSprite.Color;

            ccColor4B color = new ccColor4B {
                r = c3b.r, g = c3b.g, b = c3b.b, a = op
            };

            if (m_pSprite.Texture.HasPremultipliedAlpha)
            {
                color.r *= (byte)(op / 255);
                color.g *= (byte)(op / 255);
                color.b *= (byte)(op / 255);
            }

            if (m_pVertexData != null)
            {
                for (int i = 0; i < m_nVertexDataCount; ++i)
                {
                    m_pVertexData[i].colors = color;
                }
            }
        }
 /// <summary>
 /// Initializes the CCLayer with a gradient between start and end.
 /// </summary>
 public virtual bool initWithColor(ccColor4B start, ccColor4B end)
 {
     return initWithColor(start, end, new CCPoint(0, -1));
 }
        protected override void updateColor()
        {
            base.updateColor();

            float h = CCPointExtension.ccpLength(m_AlongVector);
            if (h == 0)
                return;

            double c = Math.Sqrt(2.0);
            CCPoint u = new CCPoint(m_AlongVector.x / h, m_AlongVector.y / h);

            // Compressed Interpolation mode
            if (m_bCompressedInterpolation)
            {
                float h2 = 1 / (Math.Abs(u.x) + Math.Abs(u.y));
                u = CCPointExtension.ccpMult(u, h2 * (float)c);
            }

            float opacityf = (float)m_cOpacity / 255.0f;

            ccColor4B S = new ccColor4B
            {
                r = m_tColor.r,
                g = m_tColor.g,
                b = m_tColor.b,
                a = (byte)(m_cStartOpacity * opacityf)
            };

            ccColor4B E = new ccColor4B
            {
                r = m_endColor.r,
                g = m_endColor.g,
                b = m_endColor.b,
                a = (byte)(m_cEndOpacity * opacityf)
            };

            // (-1, -1)
            m_pSquareColors[0].r = (byte)(E.r + (S.r - E.r) * ((c + u.x + u.y) / (2.0f * c)));
            m_pSquareColors[0].g = (byte)(E.g + (S.g - E.g) * ((c + u.x + u.y) / (2.0f * c)));
            m_pSquareColors[0].b = (byte)(E.b + (S.b - E.b) * ((c + u.x + u.y) / (2.0f * c)));
            m_pSquareColors[0].a = (byte)(E.a + (S.a - E.a) * ((c + u.x + u.y) / (2.0f * c)));
            // (1, -1)
            m_pSquareColors[1].r = (byte)(E.r + (S.r - E.r) * ((c - u.x + u.y) / (2.0f * c)));
            m_pSquareColors[1].g = (byte)(E.g + (S.g - E.g) * ((c - u.x + u.y) / (2.0f * c)));
            m_pSquareColors[1].b = (byte)(E.b + (S.b - E.b) * ((c - u.x + u.y) / (2.0f * c)));
            m_pSquareColors[1].a = (byte)(E.a + (S.a - E.a) * ((c - u.x + u.y) / (2.0f * c)));
            // (-1, 1)
            m_pSquareColors[2].r = (byte)(E.r + (S.r - E.r) * ((c + u.x - u.y) / (2.0f * c)));
            m_pSquareColors[2].g = (byte)(E.g + (S.g - E.g) * ((c + u.x - u.y) / (2.0f * c)));
            m_pSquareColors[2].b = (byte)(E.b + (S.b - E.b) * ((c + u.x - u.y) / (2.0f * c)));
            m_pSquareColors[2].a = (byte)(E.a + (S.a - E.a) * ((c + u.x - u.y) / (2.0f * c)));
            // (1, 1)
            m_pSquareColors[3].r = (byte)(E.r + (S.r - E.r) * ((c - u.x - u.y) / (2.0f * c)));
            m_pSquareColors[3].g = (byte)(E.g + (S.g - E.g) * ((c - u.x - u.y) / (2.0f * c)));
            m_pSquareColors[3].b = (byte)(E.b + (S.b - E.b) * ((c - u.x - u.y) / (2.0f * c)));
            m_pSquareColors[3].a = (byte)(E.a + (S.a - E.a) * ((c - u.x - u.y) / (2.0f * c)));

            vertices[0].Color = new Color(m_pSquareColors[0].r, m_pSquareColors[0].g, m_pSquareColors[0].b, m_pSquareColors[0].a);
            vertices[1].Color = new Color(m_pSquareColors[1].r, m_pSquareColors[1].g, m_pSquareColors[1].b, m_pSquareColors[1].a);
            vertices[2].Color = new Color(m_pSquareColors[2].r, m_pSquareColors[2].g, m_pSquareColors[2].b, m_pSquareColors[2].a);
            vertices[3].Color = new Color(m_pSquareColors[3].r, m_pSquareColors[3].g, m_pSquareColors[3].b, m_pSquareColors[3].a);
        }
        /// <summary>
        /// Initializes the CCLayer with a gradient between start and end in the direction of v.
        /// </summary>
        public virtual bool initWithColor(ccColor4B start, ccColor4B end, CCPoint v)
        {
            m_endColor = new ccColor3B();
            m_endColor.r = end.r;
            m_endColor.g = end.g;
            m_endColor.b = end.b;

            m_cEndOpacity = end.a;
            m_cStartOpacity = start.a;
            m_AlongVector = v;

            m_bCompressedInterpolation = true;

            return base.initWithColor(new ccColor4B(start.r, start.g, start.b, 255));
        }
        public override void updateQuadWithParticle(CCParticle particle, CCPoint newPosition)
        {
            // colors
            ccV2F_C4B_T2F_Quad quad = m_pQuads[m_uParticleIdx];

            ccColor4B color = new ccColor4B( (Byte)(particle.color.r * 255), (Byte)(particle.color.g * 255), (Byte)(particle.color.b * 255), 
		(Byte)(particle.color.a * 255));
            quad.bl.colors = color;
            quad.br.colors = color;
            quad.tl.colors = color;
            quad.tr.colors = color;

            // vertices
            float size_2 = particle.size / 2;
            if (particle.rotation != 0)
            {
                float x1 = -size_2;
                float y1 = -size_2;

                float x2 = size_2;
                float y2 = size_2;
                float x = newPosition.x;
                float y = newPosition.y;

                float r = - ccMacros.CC_DEGREES_TO_RADIANS(particle.rotation); 
                float cr = (float)System.Math.Cos(r);
                float sr = (float)System.Math.Sin(r);
                float ax = x1 * cr - y1 * sr + x;
                float ay = x1 * sr + y1 * cr + y;
                float bx = x2 * cr - y1 * sr + x;
                float by = x2 * sr + y1 * cr + y;
                float cx = x2 * cr - y2 * sr + x;
                float cy = x2 * sr + y2 * cr + y;
                float dx = x1 * cr - y2 * sr + x;
                float dy = x1 * sr + y2 * cr + y;

                // bottom-left
                quad.bl.vertices.x = ax;
                quad.bl.vertices.y = ay;

                // bottom-right vertex:
                quad.br.vertices.x = bx;
                quad.br.vertices.y = by;

                // top-left vertex:
                quad.tl.vertices.x = dx;
                quad.tl.vertices.y = dy;

                // top-right vertex:
                quad.tr.vertices.x = cx;
                quad.tr.vertices.y = cy;
            }
            else
            {
                // bottom-left vertex:
                quad.bl.vertices.x = newPosition.x - size_2;
                quad.bl.vertices.y = newPosition.y - size_2;

                // bottom-right vertex:
                quad.br.vertices.x = newPosition.x + size_2;
                quad.br.vertices.y = newPosition.y - size_2;

                // top-left vertex:
                quad.tl.vertices.x = newPosition.x - size_2;
                quad.tl.vertices.y = newPosition.y + size_2;

                // top-right vertex:
                quad.tr.vertices.x = newPosition.x + size_2;
                quad.tr.vertices.y = newPosition.y + size_2;
            }
        }
        public override void onEnter()
        {
            base.onEnter();

            // create a transparent color layer
            // in which we are going to add our rendertextures
            ccColor4B color = new ccColor4B(0, 0, 0, 0);
            CCSize size = CCDirector.sharedDirector().getWinSize();
            //CCLayerColor layer = CCLayerColor.layerWithColor(color);

            CCLayer layer = new CCLayer();

            // create the first render texture for inScene
            CCRenderTexture inTexture = CCRenderTexture.renderTextureWithWidthAndHeight((int)size.width, (int)size.height);

            if (null == inTexture)
            {
                return;
            }

            inTexture.Sprite.anchorPoint = new CCPoint(0.5f, 0.5f);
            inTexture.position = new CCPoint(size.width / 2, size.height / 2);
            inTexture.anchorPoint = new CCPoint(0.5f, 0.5f);

            //  render inScene to its texturebuffer
            inTexture.begin();
            m_pInScene.visit();
            inTexture.end();

            // create the second render texture for outScene
            CCRenderTexture outTexture = CCRenderTexture.renderTextureWithWidthAndHeight((int)size.width, (int)size.height);
            outTexture.Sprite.anchorPoint = new CCPoint(0.5f, 0.5f);
            outTexture.position = new CCPoint(size.width / 2, size.height / 2);
            outTexture.anchorPoint = new CCPoint(0.5f, 0.5f);

            //  render outScene to its texturebuffer
            outTexture.begin();
            m_pOutScene.visit();
            outTexture.end();

            // create blend functions

            ccBlendFunc blend1 = new ccBlendFunc(OGLES.GL_ONE, OGLES.GL_ONE); // inScene will lay on background and will not be used with alpha
            ccBlendFunc blend2 = new ccBlendFunc(OGLES.GL_SRC_ALPHA, OGLES.GL_ONE_MINUS_SRC_ALPHA); // we are going to blend outScene via alpha

            // set blendfunctions
            inTexture.Sprite.BlendFunc = blend1;
            outTexture.Sprite.BlendFunc = blend2;

            // add render textures to the layer
            layer.addChild(inTexture);
            layer.addChild(outTexture);

            // initial opacity:
            inTexture.Sprite.Opacity = 255;
            outTexture.Sprite.Opacity = 255;

            // create the blend action
            CCAction layerAction = CCSequence.actions
            (
                CCFadeTo.actionWithDuration(m_fDuration, 0),
                CCCallFunc.actionWithTarget(this, (base.hideOutShowIn)),
                CCCallFunc.actionWithTarget(this, (base.finish))
            );

            //// run the blend action
            outTexture.Sprite.runAction(layerAction);

            // add the layer (which contains our two rendertextures) to the scene
            addChild(layer, 2, kSceneFade);
        }
Esempio n. 35
0
        public virtual bool init()
        {
            m_bDirty = m_bRecursiveDirty = false;

            // by default use "Self Render".
            // if the sprite is added to an batchnode, then it will automatically switch to "SpriteSheet Render"
            useSelfRender();

            m_bOpacityModifyRGB = true;
            m_nOpacity = 255;
            m_sColor = new ccColor3B(255, 255, 255);
            m_sColorUnmodified = new ccColor3B(255, 255, 255);

            m_sBlendFunc = new ccBlendFunc();
            m_sBlendFunc.src = ccMacros.CC_BLEND_SRC;
            m_sBlendFunc.dst = ccMacros.CC_BLEND_DST;

            // update texture (calls updateBlendFunc)
            Texture = null;

            // clean the Quad
            m_sQuad = new ccV3F_C4B_T2F_Quad();

            m_bFlipX = m_bFlipY = false;

            // default transform anchor: center
            AnchorPoint = (CCPointExtension.ccp(0.5f, 0.5f));

            // zwoptex default values
            m_obOffsetPositionInPixels = new CCPoint();

            m_eHonorParentTransform = ccHonorParentTransform.CC_HONOR_PARENT_TRANSFORM_ALL;
            m_bHasChildren = false;

            // Atlas: Color
            ccColor4B tmpColor = new ccColor4B(255, 255, 255, 255);
            m_sQuad.bl.colors = tmpColor;
            m_sQuad.br.colors = tmpColor;
            m_sQuad.tl.colors = tmpColor;
            m_sQuad.tr.colors = tmpColor;

            // Atlas: Vertex

            // updated in "useSelfRender"

            // Atlas: TexCoords

            setTextureRectInPixels(new CCRect(), false, new CCSize());

            return true;
        }
Esempio n. 36
0
        public void tintWithColor(ccColor3B colors)
        {
            Color = colors;

            for (int i = 0; i < m_uNuPoints * 2; i++)
            {
                m_pColor[i] = new ccColor4B(colors);
                //        *((ccColor3B*) (m_pColorPointer+i*4)) = colors;
            }
        }
Esempio n. 37
0
 //! helper macro that creates an ccColor4B type
 public static ccColor4B ccc4(byte r, byte g, byte b, byte o)
 {
     ccColor4B c = new ccColor4B(r, g, b, o);
     return c;
 }
Esempio n. 38
0
 /** Returns a ccColor4F from a ccColor4B.
  @since v0.99.1
  */
 public static ccColor4F ccc4FFromccc4B(ccColor4B c)
 {
     ccColor4F c4 = new ccColor4F(c.r / 255.0f, c.g / 255.0f, c.b / 255.0f, c.a / 255.0f);
     return c4;
 }
Esempio n. 39
0
 public ccColor4B(ccColor4B copy)
 {
     r = copy.r;
     g = copy.g;
     b = copy.b;
     a = copy.a;
 }
Esempio n. 40
0
        public float size; // 4 bytes

        #endregion Fields

        #region Constructors

        public ccPointSprite()
        {
            pos = new ccVertex2F();
            color = new ccColor4B();
            size = 0.0f;
        }
Esempio n. 41
0
        /// <summary>
        /// creates a CCLayer with color, width and height in Points
        /// </summary>
        public static CCLayerColor layerWithColorWidthHeight(ccColor4B color, float width, float height)
        {
            CCLayerColor pLayer = new CCLayerColor();
            if (pLayer.initWithColorWidthHeight(color, width, height))
            {
                return pLayer;
            }

            return null;
        }
Esempio n. 42
0
        public override void update(float delta)
        {
            if (!m_bStartingPositionInitialized)
            {
                return;
            }

            if (m_pVerticesPCT == null)
            {
                m_pVerticesPCT = new VertexPositionColorTexture[((m_uNuPoints + 1) * 2)];
            }
            if (m_uNuPoints * 2 > m_pVerticesPCT.Length)
            {
                VertexPositionColorTexture[] tmp = new VertexPositionColorTexture[((m_uNuPoints + 1) * 2)];
                m_pVerticesPCT.CopyTo(tmp, 0);
                m_pVerticesPCT = tmp;
            }
            delta *= m_fFadeDelta;

            int newIdx, newIdx2, i, i2;
            int mov = 0;

            // Update current points
            for (i = 0; i < m_uNuPoints; i++)
            {
                if (m_pVerticesPCT[i] == null)
                {
                    m_pVerticesPCT[i] = new VertexPositionColorTexture(m_pVertices[i].ToVector3(), m_pColor[i].XNAColor, m_pTexCoords[i].ToVector2());
                }
                if (m_pVerticesPCT[i * 2] == null)
                {
                    m_pVerticesPCT[i * 2] = new VertexPositionColorTexture(m_pVerticesPCT[i].Position, m_pVerticesPCT[i].Color, m_pVerticesPCT[i].TextureCoordinate);
                }
                m_pPointState[i] -= delta;

                if (m_pPointState[i] <= 0)
                {
                    mov++;
                }
                else
                {
                    newIdx = i - mov;

                    if (mov > 0)
                    {
                        // Move data
                        m_pPointState[newIdx] = m_pPointState[i];

                        // Move point
                        m_pPointVertexes[newIdx] = new CCPoint(m_pPointVertexes[i]);

                        // Move vertices
                        i2      = i * 2;
                        newIdx2 = newIdx * 2;
                        m_pVertices[newIdx2]     = new ccVertex2F(m_pVertices[i2]);
                        m_pVertices[newIdx2 + 1] = new ccVertex2F(m_pVertices[i2 + 1]);
                        // Move color
                        m_pColor[newIdx2]     = new ccColor4B(m_pColor[i2]);
                        m_pColor[newIdx2 + 1] = new ccColor4B(m_pColor[i2 + 1]);
                        // Move the GL vertex data
                        m_pVerticesPCT[newIdx2]     = m_pVerticesPCT[i2];
                        m_pVerticesPCT[newIdx2 + 1] = m_pVerticesPCT[i2 + 1];
                    }
                    else
                    {
                        newIdx2 = newIdx * 2;
                    }
                    byte op = (byte)(m_pPointState[newIdx] * 255.0f);
                    m_pColor[newIdx2].a     = op;
                    m_pColor[newIdx2 + 1].a = op;
                    VertexPositionColorTexture vpc;
                    if (m_pVertices[newIdx2] != null)
                    {
                        vpc = new VertexPositionColorTexture(m_pVertices[newIdx2].ToVector3(), m_pColor[newIdx2].XNAColor, m_pTexCoords[newIdx2].ToVector2());
                        m_pVerticesPCT[newIdx2] = vpc;
                    }
                    if (m_pVertices[newIdx2 + 1] != null)
                    {
                        vpc = new VertexPositionColorTexture(m_pVertices[newIdx2 + 1].ToVector3(), m_pColor[newIdx2 + 1].XNAColor, m_pTexCoords[newIdx2 + 1].ToVector2());
                        m_pVerticesPCT[newIdx2 + 1] = vpc;
                    }
                }
            }
            m_uNuPoints -= mov;

            // Append new point
            bool appendNewPoint = true;

            if (m_uNuPoints >= m_uMaxPoints)
            {
                appendNewPoint = false;
            }

            else if (m_uNuPoints > 0)
            {
                bool a1 = (m_pPointVertexes[m_uNuPoints - 1].DistanceSQ(m_tPositionR) < m_fMinSeg);
                bool a2 = (m_uNuPoints == 1) ? false : (m_pPointVertexes[m_uNuPoints - 2].DistanceSQ(m_tPositionR) < (m_fMinSeg * 2.0f));
                if (a1 || a2)
                {
                    appendNewPoint = false;
                }
            }

            if (appendNewPoint)
            {
                m_pPointVertexes[m_uNuPoints] = new CCPoint(m_tPositionR);
                m_pPointState[m_uNuPoints]    = 1.0f;

                // Color asignment
                int offset = m_uNuPoints * 2;
                m_pColor[offset]     = new ccColor4B(m_tColor);
                m_pColor[offset + 1] = new ccColor4B(m_tColor);

                // Opacity
                m_pColor[offset].a     = 255;
                m_pColor[offset + 1].a = 255;

                // Generate polygon
                if (m_uNuPoints > 0 && m_bFastMode)
                {
                    if (m_uNuPoints > 1)
                    {
                        CCVertex.LineToPolygon(m_pPointVertexes, m_fStroke, m_pVertices, m_uNuPoints, 1);
                    }
                    else
                    {
                        CCVertex.LineToPolygon(m_pPointVertexes, m_fStroke, m_pVertices, 0, 2);
                    }
                }

                m_uNuPoints++;
            }

            if (!m_bFastMode)
            {
                CCVertex.LineToPolygon(m_pPointVertexes, m_fStroke, m_pVertices, 0, m_uNuPoints);
            }

            // Updated Tex Coords only if they are different than previous step
            if (m_uPreviousNuPoints != m_uNuPoints)
            {
                if (m_uNuPoints > m_uPreviousNuPoints)
                {
                    int count = (m_uNuPoints + 1) * 2;
                    if (count < m_pVerticesPCT.Length)
                    {
                        count = m_pVerticesPCT.Length;
                    }
                    VertexPositionColorTexture[] tmp = new VertexPositionColorTexture[count];
                    m_pVerticesPCT.CopyTo(tmp, 0);
                    m_pVerticesPCT = tmp;
                }
                float texDelta = 1.0f / m_uNuPoints;
                for (i = 0; i < m_uNuPoints; i++)
                {
                    m_pTexCoords[i * 2]     = new ccTex2F(0, texDelta * i);
                    m_pTexCoords[i * 2 + 1] = new ccTex2F(1, texDelta * i);
                    VertexPositionColorTexture vpc;
                    if (m_pVertices[i * 2] != null)
                    {
                        vpc = new VertexPositionColorTexture(m_pVertices[i * 2].ToVector3(), m_pColor[i * 2].XNAColor, m_pTexCoords[i * 2].ToVector2());
                        m_pVerticesPCT[i * 2] = vpc;
                    }
                    if (m_pVertices[i * 2 + 1] != null)
                    {
                        vpc = new VertexPositionColorTexture(m_pVertices[i * 2 + 1].ToVector3(), m_pColor[i * 2 + 1].XNAColor, m_pTexCoords[i * 2 + 1].ToVector2());
                        m_pVerticesPCT[i * 2 + 1] = vpc;
                    }
                }

                m_uPreviousNuPoints = m_uNuPoints;
            }
        }
Esempio n. 43
0
 /// <summary>
 /// initializes a CCLayer with color. Width and height are the window size.
 /// </summary>
 public virtual bool initWithColor(ccColor4B color)
 {
     CCSize s = CCDirector.sharedDirector().getWinSize();
     this.initWithColorWidthHeight(color, s.width, s.height);
     return true;
 }
Esempio n. 44
0
 public virtual bool initWithColor(ccColor4B start, ccColor4B end)
 {
     return(this.initWithColor(start, end, new CCPoint(0f, -1f)));
 }
Esempio n. 45
0
        public ccVertex3F vertices; // 12 bytes

        #endregion Fields

        #region Constructors

        public ccV3F_C4B_T2F()
        {
            vertices = new ccVertex3F();
            colors = new ccColor4B();
            texCoords = new ccTex2F();
        }
Esempio n. 46
0
        protected void updateColor()
        {
            byte op = m_pSprite.Opacity;
            ccColor3B c3b = m_pSprite.Color;

            ccColor4B color = new ccColor4B { r = c3b.r, g = c3b.g, b = c3b.b, a = op };
            if (m_pSprite.Texture.HasPremultipliedAlpha)
            {
                color.r *= (byte)(op / 255);
                color.g *= (byte)(op / 255);
                color.b *= (byte)(op / 255);
            }

            if (m_pVertexData != null)
            {
                for (int i = 0; i < m_nVertexDataCount; ++i)
                {
                    m_pVertexData[i].colors = color;
                }
            }
        }
Esempio n. 47
0
        public override void updateQuadWithParticle(CCParticle particle, CCPoint newPosition)
        {
            // colors
            ccV2F_C4B_T2F_Quad quad = m_pQuads[m_uParticleIdx];

            ccColor4B color = new ccColor4B((Byte)(particle.color.r * 255), (Byte)(particle.color.g * 255), (Byte)(particle.color.b * 255),
                                            (Byte)(particle.color.a * 255));

            quad.bl.colors = color;
            quad.br.colors = color;
            quad.tl.colors = color;
            quad.tr.colors = color;

            // vertices
            float size_2 = particle.size / 2;

            if (particle.rotation != 0)
            {
                float x1 = -size_2;
                float y1 = -size_2;

                float x2 = size_2;
                float y2 = size_2;
                float x  = newPosition.X;
                float y  = newPosition.Y;

                float r  = -CCUtils.CC_DEGREES_TO_RADIANS(particle.rotation);
                float cr = (float)System.Math.Cos(r);
                float sr = (float)System.Math.Sin(r);
                float ax = x1 * cr - y1 * sr + x;
                float ay = x1 * sr + y1 * cr + y;
                float bx = x2 * cr - y1 * sr + x;
                float by = x2 * sr + y1 * cr + y;
                float cx = x2 * cr - y2 * sr + x;
                float cy = x2 * sr + y2 * cr + y;
                float dx = x1 * cr - y2 * sr + x;
                float dy = x1 * sr + y2 * cr + y;

                // bottom-left
                quad.bl.vertices.x = ax;
                quad.bl.vertices.y = ay;

                // bottom-right vertex:
                quad.br.vertices.x = bx;
                quad.br.vertices.y = by;

                // top-left vertex:
                quad.tl.vertices.x = dx;
                quad.tl.vertices.y = dy;

                // top-right vertex:
                quad.tr.vertices.x = cx;
                quad.tr.vertices.y = cy;
            }
            else
            {
                // bottom-left vertex:
                quad.bl.vertices.x = newPosition.X - size_2;
                quad.bl.vertices.y = newPosition.Y - size_2;

                // bottom-right vertex:
                quad.br.vertices.x = newPosition.X + size_2;
                quad.br.vertices.y = newPosition.Y - size_2;

                // top-left vertex:
                quad.tl.vertices.x = newPosition.X - size_2;
                quad.tl.vertices.y = newPosition.Y + size_2;

                // top-right vertex:
                quad.tr.vertices.x = newPosition.X + size_2;
                quad.tr.vertices.y = newPosition.Y + size_2;
            }
        }
Esempio n. 48
0
        public override void update(float delta)
        {
            if (!m_bStartingPositionInitialized)
            {
                return;
            }

            if (m_pVerticesPCT == null)
            {
                m_pVerticesPCT = new VertexPositionColorTexture[((m_uNuPoints + 1) * 2)];
            }
            if (m_uNuPoints * 2 > m_pVerticesPCT.Length)
            {
                VertexPositionColorTexture[] tmp = new VertexPositionColorTexture[((m_uNuPoints + 1) * 2)];
                m_pVerticesPCT.CopyTo(tmp, 0);
                m_pVerticesPCT = tmp;
            }
            delta *= m_fFadeDelta;

            int newIdx, newIdx2, i, i2;
            int mov = 0;

            // Update current points
            for (i = 0; i < m_uNuPoints; i++)
            {
                if (m_pVerticesPCT[i] == null)
                {
                    m_pVerticesPCT[i] = new VertexPositionColorTexture(m_pVertices[i].ToVector3(), m_pColor[i].XNAColor, m_pTexCoords[i].ToVector2());
                }
                if (m_pVerticesPCT[i * 2] == null)
                {
                    m_pVerticesPCT[i * 2] = new VertexPositionColorTexture(m_pVerticesPCT[i].Position, m_pVerticesPCT[i].Color, m_pVerticesPCT[i].TextureCoordinate);
                }
                m_pPointState[i] -= delta;

                if (m_pPointState[i] <= 0)
                    mov++;
                else
                {
                    newIdx = i - mov;

                    if (mov > 0)
                    {
                        // Move data
                        m_pPointState[newIdx] = m_pPointState[i];

                        // Move point
                        m_pPointVertexes[newIdx] = new CCPoint(m_pPointVertexes[i]);

                        // Move vertices
                        i2 = i * 2;
                        newIdx2 = newIdx * 2;
                        m_pVertices[newIdx2] = new ccVertex2F(m_pVertices[i2]);
                        m_pVertices[newIdx2 + 1] = new ccVertex2F(m_pVertices[i2 + 1]);
                        // Move color
                        m_pColor[newIdx2] = new ccColor4B(m_pColor[i2]);
                        m_pColor[newIdx2 + 1] = new ccColor4B(m_pColor[i2 + 1]);
                        // Move the GL vertex data
                        m_pVerticesPCT[newIdx2] = m_pVerticesPCT[i2];
                        m_pVerticesPCT[newIdx2 + 1] = m_pVerticesPCT[i2 + 1];
                    }
                    else
                    {
                        newIdx2 = newIdx * 2;
                    }
                    byte op = (byte)(m_pPointState[newIdx] * 255.0f);
                    m_pColor[newIdx2].a = op;
                    m_pColor[newIdx2 + 1].a = op;
                    VertexPositionColorTexture vpc;
                    if (m_pVertices[newIdx2] != null)
                    {
                        vpc = new VertexPositionColorTexture(m_pVertices[newIdx2].ToVector3(), m_pColor[newIdx2].XNAColor, m_pTexCoords[newIdx2].ToVector2());
                        m_pVerticesPCT[newIdx2] = vpc;
                    }
                    if (m_pVertices[newIdx2 + 1] != null)
                    {
                        vpc = new VertexPositionColorTexture(m_pVertices[newIdx2 + 1].ToVector3(), m_pColor[newIdx2 + 1].XNAColor, m_pTexCoords[newIdx2 + 1].ToVector2());
                        m_pVerticesPCT[newIdx2 + 1] = vpc;
                    }
                }
            }
            m_uNuPoints -= mov;

            // Append new point
            bool appendNewPoint = true;
            if (m_uNuPoints >= m_uMaxPoints)
            {
                appendNewPoint = false;
            }

            else if (m_uNuPoints > 0)
            {
                bool a1 = (m_pPointVertexes[m_uNuPoints - 1].DistanceSQ(m_tPositionR) < m_fMinSeg);
                bool a2 = (m_uNuPoints == 1) ? false : (m_pPointVertexes[m_uNuPoints - 2].DistanceSQ(m_tPositionR) < (m_fMinSeg * 2.0f));
                if (a1 || a2)
                {
                    appendNewPoint = false;
                }
            }

            if (appendNewPoint)
            {
                m_pPointVertexes[m_uNuPoints] = new CCPoint(m_tPositionR);
                m_pPointState[m_uNuPoints] = 1.0f;

                // Color asignment
                int offset = m_uNuPoints * 2;
                m_pColor[offset] = new ccColor4B(m_tColor);
                m_pColor[offset + 1] = new ccColor4B(m_tColor);

                // Opacity
                m_pColor[offset].a = 255;
                m_pColor[offset + 1].a = 255;

                // Generate polygon
                if (m_uNuPoints > 0 && m_bFastMode)
                {
                    if (m_uNuPoints > 1)
                    {
                        CCVertex.LineToPolygon(m_pPointVertexes, m_fStroke, m_pVertices, m_uNuPoints, 1);
                    }
                    else
                    {
                        CCVertex.LineToPolygon(m_pPointVertexes, m_fStroke, m_pVertices, 0, 2);
                    }
                }

                m_uNuPoints++;
            }

            if (!m_bFastMode)
            {
                CCVertex.LineToPolygon(m_pPointVertexes, m_fStroke, m_pVertices, 0, m_uNuPoints);
            }

            // Updated Tex Coords only if they are different than previous step
            if (m_uPreviousNuPoints != m_uNuPoints)
            {
                if (m_uNuPoints > m_uPreviousNuPoints)
                {
                    int count = (m_uNuPoints + 1) * 2;
                    if (count < m_pVerticesPCT.Length)
                    {
                        count = m_pVerticesPCT.Length;
                    }
                    VertexPositionColorTexture[] tmp = new VertexPositionColorTexture[count];
                    m_pVerticesPCT.CopyTo(tmp, 0);
                    m_pVerticesPCT = tmp;
                }
                float texDelta = 1.0f / m_uNuPoints;
                for (i = 0; i < m_uNuPoints; i++)
                {
                    m_pTexCoords[i * 2] = new ccTex2F(0, texDelta * i);
                    m_pTexCoords[i * 2 + 1] = new ccTex2F(1, texDelta * i);
                    VertexPositionColorTexture vpc;
                    if (m_pVertices[i * 2] != null)
                    {
                        vpc = new VertexPositionColorTexture(m_pVertices[i * 2].ToVector3(), m_pColor[i * 2].XNAColor, m_pTexCoords[i * 2].ToVector2());
                        m_pVerticesPCT[i * 2] = vpc;
                    }
                    if (m_pVertices[i * 2 + 1] != null)
                    {
                        vpc = new VertexPositionColorTexture(m_pVertices[i * 2 + 1].ToVector3(), m_pColor[i * 2 + 1].XNAColor, m_pTexCoords[i * 2 + 1].ToVector2());
                        m_pVerticesPCT[i * 2 + 1] = vpc;
                    }
                }

                m_uPreviousNuPoints = m_uNuPoints;
            }
        }
Esempio n. 49
0
        /// <summary>
        /// creates a CCLayer with color. Width and height are the window size. 
        /// </summary>
        public static CCLayerColor layerWithColor(ccColor4B color)
        {
            CCLayerColor pLayer = new CCLayerColor();
            if (pLayer.initWithColor(color))
            {
                return pLayer;
            }

            return null;
        }
Esempio n. 50
0
        /// <summary>
        ///  initializes a CCLayer with color, width and height in Points
        /// </summary>
        public virtual bool initWithColorWidthHeight(ccColor4B color, float width, float height)
        {
            // default blend function
            m_tBlendFunc.src = 1;
            m_tBlendFunc.dst = 0x0303;

            m_tColor.r = color.r;
            m_tColor.g = color.g;
            m_tColor.b = color.b;
            m_cOpacity = color.a;
            for (int i = 0; i < m_pSquareVertices.Length; i++)
            {
                m_pSquareVertices[i] = new ccVertex2F();
                m_pSquareVertices[i].x = 0.0f;
                m_pSquareVertices[i].y = 0.0f;

                vertices[i] = new VertexPositionColor();
            }

            indexes[0] = 0;
            indexes[0] = 1;
            indexes[0] = 2;
            indexes[0] = 2;
            indexes[0] = 1;
            indexes[0] = 3;

            this.updateColor();
            this.contentSize = new CCSize(width, height);
            return true;
        }
Esempio n. 51
0
 /// <summary>
 /// initializes a CCLayer with color. Width and height are the window size.
 /// </summary>
 public virtual bool initWithColor(ccColor4B color)
 {
     CCSize s = Director.SharedDirector.DesignSize;
     this.initWithColorWidthHeight(color, s.Width, s.Height);
     return true;
 }
 public override void updateQuadWithParticle(CCParticle particle, CCPoint newPosition)
 {
     // place vertices and colos in array
     m_pVertices[m_uParticleIdx].pos = ccTypes.vertex2(newPosition.x, newPosition.y);
     m_pVertices[m_uParticleIdx].size = particle.size;
     ccColor4B color = new ccColor4B((Byte)(particle.color.r * 255), (Byte)(particle.color.g * 255), (Byte)(particle.color.b * 255),
     (Byte)(particle.color.a * 255));
     m_pVertices[m_uParticleIdx].color = color;
 }
Esempio n. 53
0
        protected virtual void updateColor()
        {
            for (int i = 0; i < 4; i++)
            {
                m_pSquareColors[i] = new ccColor4B();
                m_pSquareColors[i].r = m_tColor.r;
                m_pSquareColors[i].g = m_tColor.g;
                m_pSquareColors[i].b = m_tColor.b;
                m_pSquareColors[i].a = m_cOpacity;

                vertices[i].Color = new Microsoft.Xna.Framework.Color(m_tColor.r, m_tColor.g, m_tColor.b, m_cOpacity);
            }
        }
Esempio n. 54
0
 public ccV3F_C4B_T2F()
 {
     this.vertices  = new ccVertex3F();
     this.colors    = new ccColor4B();
     this.texCoords = new ccTex2F();
 }
Esempio n. 55
0
        /** Returns a ccColor4F from a ccColor4B.
         * @since v0.99.1
         */
        public static ccColor4F ccc4FFromccc4B(ccColor4B c)
        {
            ccColor4F c4 = new ccColor4F(c.r / 255.0f, c.g / 255.0f, c.b / 255.0f, c.a / 255.0f);

            return(c4);
        }