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

            var windowSize = Layer.VisibleBoundsWorldspace.Size;
            CCRenderTexture text = new CCRenderTexture(windowSize,windowSize);
            text.Sprite.Position = windowSize.Center;
            AddChild(text.Sprite, 24);

            CCDrawNode draw = new CCDrawNode();

            // Draw polygons
            CCPoint[] points = new CCPoint[]
                {
                    new CCPoint(windowSize.Height / 4, 0),
                    new CCPoint(windowSize.Width, windowSize.Height / 5),
                    new CCPoint(windowSize.Width / 3 * 2, windowSize.Height)
                };
            draw.DrawPolygon(points, points.Length, new CCColor4F(1, 0, 0, 0.5f), 4, new CCColor4F(0, 0, 1, 1));
            draw.AnchorPoint = CCPoint.AnchorLowerLeft;

            text.Begin();
            draw.Visit();
            text.End();        
        }
        public override void OnEnter()
        {
            base.OnEnter(); 

            CCDrawNode circle = new CCDrawNode();
            circle.DrawSolidCircle(new CCPoint(150.0f, 150.0f), 75.0f, new CCColor4B(255, 255, 255, 255));

            CCRenderTexture rtm = new CCRenderTexture(new CCSize(200.0f, 200.0f), new CCSize(200.0f, 200.0f), CCSurfaceFormat.Color, CCDepthFormat.Depth24Stencil8);
            rtm.BeginWithClear(CCColor4B.Orange);
            circle.Visit(); // Draw to rendertarget
            rtm.End();

            // Create a new sprite from the render target texture
            var sprite = new CCSprite(rtm.Texture);
            sprite.Position = VisibleBoundsWorldspace.Center;


            AddChild(sprite);
        }
        /*
         *  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();

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

            CCDrawNode circle = new CCDrawNode();
            circle.DrawSolidCircle(new CCPoint(150.0f, 150.0f), 75.0f, new CCColor4B(255, 255, 255, 255));

            CCRenderTexture rtm = new CCRenderTexture(new CCSize(200.0f, 200.0f), new CCSize(200.0f, 200.0f), CCSurfaceFormat.Color, CCDepthFormat.Depth24Stencil8);

            rtm.BeginWithClear(CCColor4B.Orange);
            circle.Visit();
            rtm.End();

            // Make sure our children nodes get visited

            rtm.Sprite.Position = VisibleBoundsWorldspace.Center;
            rtm.Sprite.AnchorPoint = CCPoint.AnchorMiddle;


            AddChild(rtm.Sprite);
        }
        /*
         *  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();

        }