Exemple #1
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);
        }
        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);
        }