예제 #1
0
        public override void onEnter()
        {
            base.onEnter();

            CCSize       s      = CCDirector.sharedDirector().getWinSize();
            CCLayerColor layer1 = CCLayerColor.layerWithColorWidthHeight(new ccColor4B(255, 255, 0, 80), 100, 300);

            layer1.position = (new CCPoint(s.width / 3, s.height / 2));
            layer1.isRelativeAnchorPoint = true;
            addChild(layer1, 1);

            CCLayerColor layer2 = CCLayerColor.layerWithColorWidthHeight(new ccColor4B(0, 0, 255, 255), 100, 300);

            layer2.position = (new CCPoint((s.width / 3) * 2, s.height / 2));
            layer2.isRelativeAnchorPoint = true;
            addChild(layer2, 1);

            CCActionInterval actionTint     = CCTintBy.actionWithDuration(2, -255, -127, 0);
            CCActionInterval actionTintBack = (CCActionInterval)actionTint.reverse();
            CCActionInterval seq1           = (CCActionInterval)CCSequence.actions(actionTint, actionTintBack);

            layer1.runAction(seq1);

            CCActionInterval actionFade     = CCFadeOut.actionWithDuration(2.0f);
            CCActionInterval actionFadeBack = (CCActionInterval)actionFade.reverse();
            CCActionInterval seq2           = (CCActionInterval)CCSequence.actions(actionFade, actionFadeBack);

            layer2.runAction(seq2);
        }
예제 #2
0
        public SpriteColorOpacity()
        {
            CCSprite sprite1 = CCSprite.spriteWithFile("Images/grossini_dance_atlas", new CCRect(85 * 0, 121 * 1, 85, 121));
            CCSprite sprite2 = CCSprite.spriteWithFile("Images/grossini_dance_atlas", new CCRect(85 * 1, 121 * 1, 85, 121));
            CCSprite sprite3 = CCSprite.spriteWithFile("Images/grossini_dance_atlas", new CCRect(85 * 2, 121 * 1, 85, 121));
            CCSprite sprite4 = CCSprite.spriteWithFile("Images/grossini_dance_atlas", new CCRect(85 * 3, 121 * 1, 85, 121));

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

            CCSize s = CCDirector.sharedDirector().getWinSize();

            sprite1.position = new CCPoint((s.width / 5) * 1, (s.height / 3) * 1);
            sprite2.position = new CCPoint((s.width / 5) * 2, (s.height / 3) * 1);
            sprite3.position = new CCPoint((s.width / 5) * 3, (s.height / 3) * 1);
            sprite4.position = new CCPoint((s.width / 5) * 4, (s.height / 3) * 1);
            sprite5.position = new CCPoint((s.width / 5) * 1, (s.height / 3) * 2);
            sprite6.position = new CCPoint((s.width / 5) * 2, (s.height / 3) * 2);
            sprite7.position = new CCPoint((s.width / 5) * 3, (s.height / 3) * 2);
            sprite8.position = new CCPoint((s.width / 5) * 4, (s.height / 3) * 2);

            CCActionInterval action      = CCFadeIn.actionWithDuration(2);
            CCActionInterval action_back = (CCActionInterval)action.reverse();
            CCAction         fade        = CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(action, action_back)));

            CCActionInterval tintred      = CCTintBy.actionWithDuration(2, 0, -255, -255);
            CCActionInterval tintred_back = (CCActionInterval)tintred.reverse();
            CCAction         red          = CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(tintred, tintred_back)));

            CCActionInterval tintgreen      = CCTintBy.actionWithDuration(2, -255, 0, -255);
            CCActionInterval tintgreen_back = (CCActionInterval)tintgreen.reverse();
            CCAction         green          = CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(tintgreen, tintgreen_back)));

            CCActionInterval tintblue      = CCTintBy.actionWithDuration(2, -255, -255, 0);
            CCActionInterval tintblue_back = (CCActionInterval)tintblue.reverse();
            CCAction         blue          = CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(tintblue, tintblue_back)));

            sprite5.runAction(red);
            sprite6.runAction(green);
            sprite7.runAction(blue);
            sprite8.runAction(fade);

            // late add: test dirtyColor and dirtyPosition
            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);

            schedule(removeAndAddSprite, 2);
        }
예제 #3
0
        public override void onEnter()
        {
            base.onEnter();

            centerSprites(2);

            CCActionInterval   action1     = CCTintTo.actionWithDuration(2, 255, 0, 255);
            CCActionInterval   action2     = CCTintBy.actionWithDuration(2, -127, -255, -127);
            CCFiniteTimeAction action2Back = action2.reverse();

            m_tamara.runAction(action1);
            m_kathia.runAction(CCSequence.actions(action2, action2Back));
        }
예제 #4
0
        public void addNewSprite()
        {
            CCSize s = CCDirector.sharedDirector().getWinSize();

            CCPoint p = new CCPoint((float)(rand.NextDouble() * s.width), (float)(rand.NextDouble() * s.height));

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


            CCNode   node   = getChildByTag((int)kTags.kTagSpriteBatchNode);
            CCSprite sprite = CCSprite.spriteWithTexture(m_texture1, new CCRect(x, y, 85, 121));

            node.addChild(sprite);

            sprite.position = (new CCPoint(p.x, p.y));

            CCActionInterval action;
            float            random = (float)rand.NextDouble();

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

            CCActionInterval action_back = (CCActionInterval)action.reverse();
            CCActionInterval seq         = (CCActionInterval)(CCSequence.actions(action, action_back));

            sprite.runAction(CCRepeatForever.actionWithAction(seq));
        }
        public void addNewSpriteWithCoords(CCPoint p)
        {
            CCSpriteBatchNode BatchNode = (CCSpriteBatchNode)getChildByTag((int)kTags.kTagSpriteBatchNode);

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


            CCSprite sprite = CCSprite.spriteWithTexture(BatchNode.Texture, new CCRect(x, y, 85, 121));

            BatchNode.addChild(sprite);

            sprite.position = (new CCPoint(p.x, p.y));

            CCActionInterval action = null;
            float            random = (float)rand.NextDouble();

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

            CCActionInterval action_back = (CCActionInterval)action.reverse();
            CCActionInterval seq         = (CCActionInterval)(CCSequence.actions(action, action_back));

            sprite.runAction(CCRepeatForever.actionWithAction(seq));
        }
예제 #6
0
        public void addNewSpriteWithCoords(CCPoint p)
        {
            int idx = (int)(ccMacros.CCRANDOM_0_1() * 1400.0f / 100.0f);
            int x   = (idx % 5) * 85;
            int y   = (idx / 5) * 121;

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

            addChild(sprite);

            sprite.position = p;

            CCActionInterval action;
            float            random = ccMacros.CCRANDOM_0_1();

            if (random < 0.20)
            {
                action = CCScaleBy.actionWithDuration(3, 2);
            }
            else if (random < 0.40)
            {
                action = CCRotateBy.actionWithDuration(3, 360);
            }
            else if (random < 0.60)
            {
                action = CCBlink.actionWithDuration(1, 3);
            }
            else if (random < 0.8)
            {
                action = CCTintBy.actionWithDuration(2, 0, -255, -255);
            }
            else
            {
                action = CCFadeOut.actionWithDuration(2);
            }
            object           obj         = action.reverse();
            CCActionInterval action_back = (CCActionInterval)action.reverse();
            CCActionInterval seq         = (CCActionInterval)(CCSequence.actions(action, action_back));

            sprite.runAction(CCRepeatForever.actionWithAction(seq));
        }
예제 #7
0
        public MenuLayer1()
        {
            CCMenuItemFont.FontSize = 30;
            CCMenuItemFont.FontName = "Arial";
            base.isTouchEnabled     = true;
            // Font Item

            CCSprite spriteNormal   = CCSprite.spriteWithFile(s_MenuItem, new CCRect(0, 23 * 2, 115, 23));
            CCSprite spriteSelected = CCSprite.spriteWithFile(s_MenuItem, new CCRect(0, 23 * 1, 115, 23));
            CCSprite spriteDisabled = CCSprite.spriteWithFile(s_MenuItem, new CCRect(0, 23 * 0, 115, 23));

            CCMenuItemSprite item1 = CCMenuItemSprite.itemFromNormalSprite(spriteNormal, spriteSelected, spriteDisabled, this, this.menuCallback);

            // Image Item
            CCMenuItem item2 = CCMenuItemImage.itemFromNormalImage(s_SendScore, s_PressSendScore, this, this.menuCallback2);

            // Label Item (LabelAtlas)
            CCLabelAtlas    labelAtlas = CCLabelAtlas.labelWithString("0123456789", "Images/fps_images", 16, 24, '.');
            CCMenuItemLabel item3      = CCMenuItemLabel.itemWithLabel(labelAtlas, this, this.menuCallbackDisabled);

            item3.DisabledColor = new ccColor3B(32, 32, 64);
            item3.Color         = new ccColor3B(200, 200, 255);

            // Font Item
            CCMenuItemFont item4 = CCMenuItemFont.itemFromString("I toggle enable items", this, this.menuCallbackEnable);

            item4.FontSizeObj = 20;
            item4.FontNameObj = "Arial";

            // Label Item (CCLabelBMFont)
            CCLabelBMFont   label = CCLabelBMFont.labelWithString("configuration", "fonts/fnt/bitmapFontTest3");
            CCMenuItemLabel item5 = CCMenuItemLabel.itemWithLabel(label, this, this.menuCallbackConfig);


            // Testing issue #500
            item5.scale = 0.8f;

            // Font Item
            CCMenuItemFont item6 = CCMenuItemFont.itemFromString("Quit", this, this.onQuit);

            CCActionInterval   color_action = CCTintBy.actionWithDuration(0.5f, 0, -255, -255);
            CCActionInterval   color_back   = (CCActionInterval)color_action.reverse();
            CCFiniteTimeAction seq          = CCSequence.actions(color_action, color_back);

            item6.runAction(CCRepeatForever.actionWithAction((CCActionInterval)seq));

            CCMenu menu = CCMenu.menuWithItems(item1, item2, item3, item4, item5, item6);

            menu.alignItemsVertically();

            // elastic effect
            CCSize        s = CCDirector.sharedDirector().getWinSize();
            int           i = 0;
            CCNode        child;
            List <CCNode> pArray  = menu.children;
            CCObject      pObject = null;

            if (pArray.Count > 0)
            {
                for (int j = 0; j < pArray.Count; j++)
                {
                    pObject = pArray[j];
                    if (pObject == null)
                    {
                        break;
                    }
                    child = (CCNode)pObject;
                    CCPoint dstPoint = child.position;
                    int     offset   = (int)(s.width / 2 + 50);
                    if (i % 2 == 0)
                    {
                        offset = -offset;
                    }

                    child.position = new CCPoint(dstPoint.x + offset, dstPoint.y);
                    child.runAction(CCEaseElasticOut.actionWithAction(CCMoveBy.actionWithDuration(2, new CCPoint(dstPoint.x - offset, 0)), 0.35f));
                    i++;
                }
            }
            m_disabledItem         = item3;
            m_disabledItem.Enabled = false;

            addChild(menu);
        }
예제 #8
0
 public override CCFiniteTimeAction Reverse()
 {
     return(CCTintBy.actionWithDuration(Duration, (short)-m_deltaR, (short)-m_deltaG, (short)-m_deltaB) as CCFiniteTimeAction);
 }