void AddNewSpriteWithCoords(CCPoint p)
        {
            CCSpriteBatchNode BatchNode = (CCSpriteBatchNode)GetChildByTag((int)kTags.kTagSpriteBatchNode);

            int idx = (int)(CCRandom.NextDouble() * 1400 / 100);
            int x = (idx % 5) * 85;
            int y = (idx / 5) * 121;


            CCSprite sprite = new CCSprite(BatchNode.Texture, new CCRect(x, y, 85, 121));
            sprite.Position = (new CCPoint(p.X, p.Y));
            BatchNode.AddChild(sprite);


            CCFiniteTimeAction action = null;
            float random = (float)CCRandom.NextDouble();

            if (random < 0.20)
                action = new CCScaleBy(3, 2);
            else if (random < 0.40)
                action = new CCRotateBy (3, 360);
            else if (random < 0.60)
                action = new CCBlink (1, 3);
            else if (random < 0.8)
                action = new CCTintBy (2, 0, -255, -255);
            else
                action = new CCFadeOut  (2);

            CCFiniteTimeAction action_back = (CCFiniteTimeAction)action.Reverse();
            CCFiniteTimeAction seq = (CCFiniteTimeAction)(new CCSequence(action, action_back));

            sprite.RunAction(new CCRepeatForever (seq));
        }
Exemple #2
0
        public override void OnEnter()
        {
            base.OnEnter();

            var s = Layer.VisibleBoundsWorldspace.Size;

            var layer1 = new CCLayerColor(new CCColor4B(255, 255, 0, 80));
            layer1.Position = (new CCPoint(s.Width / 3, s.Height / 2));
            layer1.IgnoreAnchorPointForPosition = false;
            AddChild(layer1, 1);

            var layer2 = new CCLayerColor(new CCColor4B(0, 0, 255, 255));
            layer2.Position = (new CCPoint((s.Width / 3) * 2, s.Height / 2));
            layer2.IgnoreAnchorPointForPosition = false;
            AddChild(layer2, 1);

            var actionTint = new CCTintBy (2, -255, -127, 0);
            var actionTintBack = actionTint.Reverse();
            var seq1 = new CCSequence(actionTint, actionTintBack);
            layer1.RunAction(seq1);

            var actionFade = new CCFadeOut(2.0f);
            var actionFadeBack = actionFade.Reverse();
            var seq2 = new CCSequence(actionFade, actionFadeBack);
            layer2.RunAction(seq2);
        }
        public SpriteBatchNodeColorOpacity()
        {
            // Small capacity. Testing resizing.
            // Don't use capacity=1 in your real game. It is expensive to resize the capacity
            CCSpriteBatchNode batch = new CCSpriteBatchNode("Images/grossini_dance_atlas", 1);
            AddChild(batch, 0, (int)kTags.kTagSpriteBatchNode);

            sprite1 = new CCSprite(batch.Texture, new CCRect(85 * 0, 121 * 1, 85, 121));
            sprite2 = new CCSprite(batch.Texture, new CCRect(85 * 1, 121 * 1, 85, 121));
            sprite3 = new CCSprite(batch.Texture, new CCRect(85 * 2, 121 * 1, 85, 121));
            sprite4 = new CCSprite(batch.Texture, new CCRect(85 * 3, 121 * 1, 85, 121));

            sprite5 = new CCSprite(batch.Texture, new CCRect(85 * 0, 121 * 1, 85, 121));
            sprite6 = new CCSprite(batch.Texture, new CCRect(85 * 1, 121 * 1, 85, 121));
            sprite7 = new CCSprite(batch.Texture, new CCRect(85 * 2, 121 * 1, 85, 121));
            sprite8 = new CCSprite(batch.Texture, new CCRect(85 * 3, 121 * 1, 85, 121));


            CCFiniteTimeAction action = new CCFadeIn  (2);
            CCFiniteTimeAction action_back = (CCFiniteTimeAction)action.Reverse();
            fade = new CCRepeatForever ((CCFiniteTimeAction)(new CCSequence(action, action_back)));

            CCFiniteTimeAction tintred = new CCTintBy (2, 0, -255, -255);
            CCFiniteTimeAction tintred_back = (CCFiniteTimeAction)tintred.Reverse();
            red = new CCRepeatForever ((CCFiniteTimeAction)(new CCSequence(tintred, tintred_back)));

            CCFiniteTimeAction tintgreen = new CCTintBy (2, -255, 0, -255);
            CCFiniteTimeAction tintgreen_back = (CCFiniteTimeAction)tintgreen.Reverse();
            green = new CCRepeatForever ((CCFiniteTimeAction)(new CCSequence(tintgreen, tintgreen_back)));

            CCFiniteTimeAction tintblue = new CCTintBy (2, -255, -255, 0);
            CCFiniteTimeAction tintblue_back = (CCFiniteTimeAction)tintblue.Reverse();
            blue = new CCRepeatForever ((CCFiniteTimeAction)(new CCSequence(tintblue, tintblue_back)));

            batch.AddChild(sprite1, 0, (int)kTagSprite.kTagSprite1);
            batch.AddChild(sprite2, 0, (int)kTagSprite.kTagSprite2);
            batch.AddChild(sprite3, 0, (int)kTagSprite.kTagSprite3);
            batch.AddChild(sprite4, 0, (int)kTagSprite.kTagSprite4);
            batch.AddChild(sprite5, 0, (int)kTagSprite.kTagSprite5);
            batch.AddChild(sprite6, 0, (int)kTagSprite.kTagSprite6);
            batch.AddChild(sprite7, 0, (int)kTagSprite.kTagSprite7);
            batch.AddChild(sprite8, 0, (int)kTagSprite.kTagSprite8);
        }
        public SpriteColorOpacity()
        {
            sprite1 = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 0, 121 * 1, 85, 121));
            sprite2 = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 1, 121 * 1, 85, 121));
            sprite3 = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 2, 121 * 1, 85, 121));
            sprite4 = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 3, 121 * 1, 85, 121));

            sprite5 = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 0, 121 * 1, 85, 121));
            sprite6 = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 1, 121 * 1, 85, 121));
            sprite7 = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 2, 121 * 1, 85, 121));
            sprite8 = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 3, 121 * 1, 85, 121));

            AddChild(sprite1, 0, (int)kTagSprite.kTagSprite1);
            AddChild(sprite2, 0, (int)kTagSprite.kTagSprite2);
            AddChild(sprite3, 0, (int)kTagSprite.kTagSprite3);
            AddChild(sprite4, 0, (int)kTagSprite.kTagSprite4);
            AddChild(sprite5, 0, (int)kTagSprite.kTagSprite5);
            AddChild(sprite6, 0, (int)kTagSprite.kTagSprite6);
            AddChild(sprite7, 0, (int)kTagSprite.kTagSprite7);
            AddChild(sprite8, 0, (int)kTagSprite.kTagSprite8);


            CCFiniteTimeAction action = new CCFadeIn  (2);
            CCFiniteTimeAction action_back = (CCFiniteTimeAction)action.Reverse();
            fade = new CCRepeatForever ((CCFiniteTimeAction)(new CCSequence(action, action_back)));

            CCFiniteTimeAction tintred = new CCTintBy (2, 0, -255, -255);
            CCFiniteTimeAction tintred_back = (CCFiniteTimeAction)tintred.Reverse();
            red = new CCRepeatForever ((CCFiniteTimeAction)(new CCSequence(tintred, tintred_back)));

            CCFiniteTimeAction tintgreen = new CCTintBy (2, -255, 0, -255);
            CCFiniteTimeAction tintgreen_back = (CCFiniteTimeAction)tintgreen.Reverse();
            green = new CCRepeatForever ((CCFiniteTimeAction)(new CCSequence(tintgreen, tintgreen_back)));

            CCFiniteTimeAction tintblue = new CCTintBy (2, -255, -255, 0);
            CCFiniteTimeAction tintblue_back = (CCFiniteTimeAction)tintblue.Reverse();
            blue = new CCRepeatForever ((CCFiniteTimeAction)(new CCSequence(tintblue, tintblue_back)));
        }
Exemple #5
0
        void AddNewSpriteWithCoords(CCPoint p)
        {
            int idx = (int)(CCMacros.CCRandomBetween0And1() * 1400.0f / 100.0f);
            int x = (idx % 5) * 85;
            int y = (idx / 5) * 121;

            CCSprite sprite = new CCSprite("Images/grossini_dance_atlas", new CCRect(x, y, 85, 121));
            AddChild(sprite);

            sprite.Position = p;

            CCFiniteTimeAction action;
            float random = CCMacros.CCRandomBetween0And1();

            if (random < 0.20)
                action = new CCScaleBy(3, 2);
            else if (random < 0.40)
                action = new CCRotateBy (3, 360);
            else if (random < 0.60)
                action = new CCBlink (1, 3);
            else if (random < 0.8)
                action = new CCTintBy (2, 0, -255, -255);
            else
                action = new CCFadeOut  (2);
            object obj = action.Reverse();
            CCFiniteTimeAction action_back = (CCFiniteTimeAction)action.Reverse();
            CCFiniteTimeAction seq = (CCFiniteTimeAction)(new CCSequence(action, action_back));

            sprite.RunAction(new CCRepeatForever (seq));
        }
Exemple #6
0
 public ActionTint()
 {
     action1 = new CCTintTo (2, 255, 0, 255);
     action2 = new CCTintBy (2, -127, -255, -127);
     action2Back = action2.Reverse();
 }
        void AddNewSprite()
        {
            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            CCPoint p = new CCPoint((float)(CCRandom.NextDouble() * s.Width), (float)(CCRandom.NextDouble() * s.Height));

            int idx = (int)(CCRandom.NextDouble() * 1400 / 100);
            int x = (idx % 5) * 85;
            int y = (idx / 5) * 121;


            CCNode node = GetChildByTag((int)kTags.kTagSpriteBatchNode);
            CCSprite sprite = new CCSprite(texture1, new CCRect(x, y, 85, 121));
            node.AddChild(sprite);

            sprite.Position = (new CCPoint(p.X, p.Y));

            CCFiniteTimeAction action;
            float random = (float)CCRandom.NextDouble();

            if (random < 0.20)
                action = new CCScaleBy(3, 2);
            else if (random < 0.40)
                action = new CCRotateBy (3, 360);
            else if (random < 0.60)
                action = new CCBlink (1, 3);
            else if (random < 0.8)
                action = new CCTintBy (2, 0, -255, -255);
            else
                action = new CCFadeOut  (2);

            CCFiniteTimeAction action_back = (CCFiniteTimeAction)action.Reverse();
            CCFiniteTimeAction seq = (CCFiniteTimeAction)(new CCSequence(action, action_back));

            sprite.RunAction(new CCRepeatForever (seq));
        }