Esempio n. 1
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCActionInterval effect = (CCSequence.FromActions(new CCDelayTime (2.0f), CCShaky3D.Create(16, false, new CCGridSize(5, 5), 5.0f)));

            // cleanup
            CCNode bg = GetChildByTag(EffectAdvanceScene.kTagBackground);
            RemoveChild(bg, true);

            // background
            CCLayerColor layer = CCLayerColor.Create(new CCColor4B(255, 0, 0, 255));
            AddChild(layer, -10);
            CCSprite sprite = new CCSprite("Images/grossini");
            sprite.Position = new CCPoint(50, 80);
            layer.AddChild(sprite, 10);

            // foreground
            CCLayerColor layer2 = CCLayerColor.Create(new CCColor4B(0, 255, 0, 255));
            CCSprite fog = new CCSprite("Images/Fog");

            var bf = new CCBlendFunc {Source = OGLES.GL_SRC_ALPHA, Destination = OGLES.GL_ONE_MINUS_SRC_ALPHA};
            fog.BlendFunc = bf;
            layer2.AddChild(fog, 1);
            AddChild(layer2, 1);

            layer2.RunAction(new CCRepeatForever (effect));
        }
Esempio n. 2
0
        public RenderTextureSave()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            // create a render texture, this is what we are going to draw into
            m_pTarget = CCRenderTexture.Create((int) s.Width, (int) s.Height, SurfaceFormat.Color, DepthFormat.None, RenderTargetUsage.PreserveContents);
            m_pTarget.Position = new CCPoint(s.Width / 2, s.Height / 2);

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

            // note that the render texture is a CCNode, and contains a sprite of its texture for convience,
            // so we can just parent it to the scene like any other CCNode
            AddChild(m_pTarget, -1);

            // create a brush image to draw into the texture with
            m_pBrush = new CCSprite("Images/fire");
            // It's possible to modify the Brushes blending function by
            CCBlendFunc bbf = new CCBlendFunc (OGLES.GL_ONE, OGLES.GL_ONE_MINUS_SRC_ALPHA);
            m_pBrush.BlendFunc = bbf;

            m_pBrush.Color = new CCColor3B (Color.Red);
            m_pBrush.Opacity = 20;
            TouchEnabled = true;

            // Save Image menu
            CCMenuItemFont.FontSize = 16;
            CCMenuItem item1 = CCMenuItemFont.Create("Save Image", saveImage);
            CCMenuItem item2 = CCMenuItemFont.Create("Clear", clearImage);
            var menu = new CCMenu(item1, item2);
            AddChild(menu);
            menu.AlignItemsVertically();
            menu.Position = new CCPoint(s.Width - 80, s.Height - 30);
        }
Esempio n. 3
0
        //protected bool m_opacityChanged;
        public CCLayerColor()
        {
            m_cOpacity = 0;
            m_tColor = new CCColor3B(0, 0, 0);

            // default blend function
            m_tBlendFunc = new CCBlendFunc(CCMacros.CCDefaultSourceBlending, CCMacros.CCDefaultDestinationBlending);
        }
Esempio n. 4
0
 protected virtual void OnHandlePropTypeBlendFunc(CCNode node, CCNode parent, string propertyName, CCBlendFunc blendFunc,
                                                  CCBReader reader)
 {
     CCLog.Log("Unexpected property type: '{0}'!", propertyName);
     Debug.Assert(false);
 }
Esempio n. 5
0
        public override void OnEnter()
        {
            base.OnEnter();

            Color = CCTypes.CCBlack;
            RemoveChild(m_background, true);
            m_background = null;

            m_emitter = CCParticleSystemQuad.Create("Particles/BoilingFoam");

            // Particle Designer "normal" blend func causes black halo on premul textures (ignores multiplication)
            //this->emitter.blendFunc = (ccBlendFunc){ GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA };

            // Cocos2d "normal" blend func for premul causes alpha to be ignored (oversaturates colors)
            var tBlendFunc = new CCBlendFunc(OGLES.GL_ONE, OGLES.GL_ONE_MINUS_SRC_ALPHA);
            m_emitter.BlendFunc = tBlendFunc;

            //Debug.Assert(m_emitter.OpacityModifyRGB, "Particle texture does not have premultiplied alpha, test is useless");

            // Toggle next line to see old behavior
            //	this->emitter.opacityModifyRGB = NO;

            m_emitter.StartColor = new CCColor4F(1, 1, 1, 1);
            m_emitter.EndColor = new CCColor4F(1, 1, 1, 0);
            m_emitter.StartColorVar = new CCColor4F(0, 0, 0, 0);
            m_emitter.EndColorVar = new CCColor4F(0, 0, 0, 0);

            AddChild(m_emitter, 10);
        }
Esempio n. 6
0
 /** Pointers */
 public CCMotionStreak()
 {
     m_tBlendFunc = new CCBlendFunc(OGLES.GL_SRC_ALPHA, OGLES.GL_ONE_MINUS_SRC_ALPHA);
 }