Пример #1
0
        public RenderTextureIssue937()
        {
            /*
            *     1    2
            * A: A1   A2
            *
            * B: B1   B2
            *
            *  A1: premulti sprite
            *  A2: premulti render
            *
            *  B1: non-premulti sprite
            *  B2: non-premulti render
            */
            CCLayerColor background = new CCLayerColor(new CCColor4B(200, 200, 200, 255));
            AddChild(background);

            CCSprite spr_premulti = new CCSprite("Images/fire");
            spr_premulti.Position = new CCPoint(16, 48);

            CCSprite spr_nonpremulti = new CCSprite("Images/fire");
            spr_nonpremulti.Position = new CCPoint(16, 16);

            /* A2 & B2 setup */
            CCRenderTexture rend = new CCRenderTexture(32, 64);

            // It's possible to modify the RenderTexture blending function by
            //CCBlendFunc bf = new CCBlendFunc (OGLES.GL_ONE, OGLES.GL_ONE_MINUS_SRC_ALPHA);
            //rend.Sprite.BlendFunc = bf;

            rend.Begin();
            // A2
            spr_premulti.Visit();
            // B2
            spr_nonpremulti.Visit();
            rend.End();

            CCSize s = CCDirector.SharedDirector.WinSize;

            /* A1: setup */
            spr_premulti.Position = new CCPoint(s.Width / 2 - 16, s.Height / 2 + 16);
            /* B1: setup */
            spr_nonpremulti.Position = new CCPoint(s.Width / 2 - 16, s.Height / 2 - 16);

            rend.Position = new CCPoint(s.Width / 2 + 16, s.Height / 2);

            AddChild(spr_nonpremulti);
            AddChild(spr_premulti);
            AddChild(rend);
        }
Пример #2
0
        public void renderScreenShot()
        {
            var size = CCDirector.SharedDirector.WinSize;
            var texture = new CCRenderTexture((int)size.Width, (int)size.Height);
            //var texture = new CCRenderTexture(512, 512);

            texture.AnchorPoint = new CCPoint(0, 0);
            texture.Begin();

            Visit();

            texture.End();

            CCSprite sprite = new CCSprite(texture.Sprite.Texture);

            //sprite.Position = new CCPoint(256, 256);
            sprite.Position = new CCPoint(size.Width/2, size.Height / 2);
            sprite.Opacity = 182;
            //sprite.IsFlipY = true;
            AddChild(sprite, 999999);
            sprite.Color = CCTypes.CCGreen;

            sprite.RunAction(
                CCSequence.FromActions(
                    new CCFadeTo (2, 0),
                    new CCHide()
                    )
                );
        }