public ColoredCircleSprite(CCColor4B color, float r)
 {
     radius_ = r;
     Opacity = color.A;
     Color = new CCColor3B(color.R, color.G, color.B);
     PreInit();
 }
        protected override void InitialiseScenes()
        {
            base.InitialiseScenes();

            // create a transparent color layer
            // in which we are going to add our rendertextures
            var color = new CCColor4B(0, 0, 0, 0);
            var bounds = Layer.VisibleBoundsWorldspace;
            CCRect viewportRect = Viewport.ViewportInPixels;

            // create the first render texture for inScene
            CCRenderTexture inTexture = new CCRenderTexture(bounds.Size, viewportRect.Size);

            if (null == inTexture)
            {
                return;
            }

            inTexture.Sprite.AnchorPoint = new CCPoint(0.5f, 0.5f);
            inTexture.Position = new CCPoint(bounds.Origin.X + bounds.Size.Width / 2, bounds.Size.Height / 2);
            inTexture.AnchorPoint = new CCPoint(0.5f, 0.5f);

            AddChild(inTexture);

            //  render inScene to its texturebuffer
            inTexture.Begin();
            InSceneNodeContainer.Visit();
            inTexture.End();

            // create the second render texture for outScene
            CCRenderTexture outTexture = new CCRenderTexture(bounds.Size, viewportRect.Size);
            outTexture.Sprite.AnchorPoint = new CCPoint(0.5f, 0.5f);
            outTexture.Position = new CCPoint(bounds.Origin.X + bounds.Size.Width / 2, bounds.Size.Height / 2);
            outTexture.AnchorPoint = new CCPoint(0.5f, 0.5f);

            AddChild(outTexture);

            //  render outScene to its texturebuffer
            outTexture.Begin();
            OutSceneNodeContainer.Visit();
            outTexture.End();

            // create blend functions

            var blend1 = new CCBlendFunc(CCOGLES.GL_ONE, CCOGLES.GL_ONE); // inScene will lay on background and will not be used with alpha
            var blend2 = CCBlendFunc.NonPremultiplied; // we are going to blend outScene via alpha 

            inTexture.Sprite.BlendFunc = blend1;
            outTexture.Sprite.BlendFunc = blend2;

            inTexture.Sprite.Opacity = 255;
            outTexture.Sprite.Opacity = 255;

            CCAction layerAction = new CCSequence
                (
                    new CCFadeTo (Duration, 0),
                    new CCCallFunc((Finish))
                );

            outTexture.Sprite.RunAction(layerAction);

            InSceneNodeContainer.Visible = false;
            OutSceneNodeContainer.Visible = false;
        }
        public override void OnEnter()
        {
            base.OnEnter();

            // create a transparent color layer
            // in which we are going to add our rendertextures
            var color = new CCColor4B(0, 0, 0, 0);
            CCSize size = CCDirector.SharedDirector.WinSize;
            CCLayerColor layer = new CCLayerColor(color);

            // create the first render texture for inScene
            CCRenderTexture inTexture = new CCRenderTexture((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 = new CCRenderTexture((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

            var blend1 = new CCBlendFunc(CCOGLES.GL_ONE, CCOGLES.GL_ONE); // inScene will lay on background and will not be used with alpha
            var blend2 = CCBlendFunc.NonPremultiplied; // 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.FromActions
                (
                    new CCFadeTo (m_fDuration, 0),
                    new CCCallFunc((HideOutShowIn)),
                    new CCCallFunc((Finish))
                );


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

            // add the layer (which contains our two rendertextures) to the scene
            AddChild(layer, 2, kSceneFade);
        }
        public SpriteWithColor(CCColor4B bgColor, float textureWidth, float textureHeight)
            : this(bgColor, new CCSize(textureWidth, textureHeight))

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

            // create a transparent color layer
            // in which we are going to add our rendertextures
            var          color = new CCColor4B(0, 0, 0, 0);
            CCSize       size  = CCDirector.SharedDirector.WinSize;
            CCLayerColor layer = new CCLayerColor(color);

            // create the first render texture for inScene
            CCRenderTexture inTexture = new CCRenderTexture((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 = new CCRenderTexture((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

            var blend1 = new CCBlendFunc(CCOGLES.GL_ONE, CCOGLES.GL_ONE); // inScene will lay on background and will not be used with alpha
            var blend2 = CCBlendFunc.NonPremultiplied;                    // 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.FromActions
                                   (
                new CCFadeTo(m_fDuration, 0),
                new CCCallFunc((HideOutShowIn)),
                new CCCallFunc((Finish))
                                   );


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

            // add the layer (which contains our two rendertextures) to the scene
            AddChild(layer, 2, kSceneFade);
        }
 public AlignmentPanel(CCColor4B color)
 {
     Color   = new CCColor3B(color);
     Opacity = color.A;
     //AnchorPoint = CCPoint.AnchorLowerLeft;
 }
Exemple #7
0
 public Background(CCColor4B color)
 {
     Color   = new CCColor3B(color);
     Opacity = color.A;
     //AnchorPoint = CCPoint.AnchorLowerLeft;
 }