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

            var s = Layer.VisibleBoundsWorldspace.Size;

            var move      = new CCMoveBy(3, new CCPoint(s.Width - 130, 0));
            var move_back = move.Reverse();

            var move_ease_in      = new CCEaseElasticIn(move);
            var move_ease_in_back = move_ease_in.Reverse();

            var move_ease_out      = new CCEaseElasticOut(move);
            var move_ease_out_back = move_ease_out.Reverse();

            var delay = new CCDelayTime(0.25f);

            var seq1 = new CCSequence(move, delay, move_back, delay);
            var seq2 = new CCSequence(move_ease_in, delay, move_ease_in_back, delay);
            var seq3 = new CCSequence(move_ease_out, delay, move_ease_out_back,
                                      delay);

            m_grossini.RunAction(new CCRepeatForever(seq1));
            m_tamara.RunAction(new CCRepeatForever(seq2));
            m_kathia.RunAction(new CCRepeatForever(seq3));
        }
Ejemplo n.º 2
0
        public override void OnEnter()
        {
            base.OnEnter();

            var s = CCDirector.SharedDirector.WinSize;

            var move      = new CCMoveBy(3, new CCPoint(s.Width - 130, 0));
            var move_back = move.Reverse();

            var move_ease_in      = new CCEaseElasticIn((CCActionInterval)(move.Copy()));
            var move_ease_in_back = move_ease_in.Reverse();

            var move_ease_out      = new CCEaseElasticOut((CCActionInterval)(move.Copy()));
            var move_ease_out_back = move_ease_out.Reverse();

            var delay = new CCDelayTime(0.25f);

            var seq1 = CCSequence.FromActions(move, delay, move_back, (CCFiniteTimeAction)delay.Copy());
            var seq2 = CCSequence.FromActions(move_ease_in, (CCFiniteTimeAction)delay.Copy(), move_ease_in_back, (CCFiniteTimeAction)delay.Copy());
            var seq3 = CCSequence.FromActions(move_ease_out, (CCFiniteTimeAction)delay.Copy(), move_ease_out_back,
                                              (CCFiniteTimeAction)delay.Copy());

            m_grossini.RunAction(new CCRepeatForever(seq1));
            m_tamara.RunAction(new CCRepeatForever(seq2));
            m_kathia.RunAction(new CCRepeatForever(seq3));
        }
Ejemplo n.º 3
0
        private void CreateLogo()
        {
            // create logo graphic
            var logo = new CCSprite("Logo.png");

            logo.BlendFunc     = CCBlendFunc.NonPremultiplied;
            logo.AnchorPoint   = new CCPoint(0, 0);
            logo.PositionX     = (base.GameView.DesignResolution.Width - logo.ContentSize.Width) / 2;
            logo.PositionY     = GameConfig.LOGO_POSITION_Y;
            logo.IsAntialiased = false;
            foregroundLayer.AddChild(logo);

            // start position
            var startPositionX = -500.0f;
            var startPositionY = GameConfig.LOGO_POSITION_Y;

            logo.PositionX = startPositionX;
            logo.PositionY = startPositionY;

            // end position
            var endPositionX = (base.GameView.DesignResolution.Width - logo.ContentSize.Width) / 2;
            var endPositionY = startPositionY;

            // create and run ease move action
            var point      = new CCPoint(endPositionX, endPositionY);
            var coreAction = new CCMoveTo(4.0f, point);
            var easeAction = new CCEaseElasticOut(coreAction);

            logo.RunAction(easeAction);
        }
Ejemplo n.º 4
0
        public override void onEnter()
        {
            base.onEnter();

            CCActionInterval move      = CCMoveBy.actionWithDuration(3, new CCPoint(350, 0));
            CCActionInterval move_back = move.reverse() as CCActionInterval;

            CCActionInterval move_ease_in      = CCEaseElasticIn.actionWithAction((CCActionInterval)(move.copy()));
            CCActionInterval move_ease_in_back = move_ease_in.reverse() as CCActionInterval;

            CCActionInterval move_ease_out      = CCEaseElasticOut.actionWithAction((CCActionInterval)(move.copy()));
            CCActionInterval move_ease_out_back = move_ease_out.reverse() as CCActionInterval;

            CCFiniteTimeAction seq1 = CCSequence.actions(move, move_back);
            CCFiniteTimeAction seq2 = CCSequence.actions(move_ease_in, move_ease_in_back);
            CCFiniteTimeAction seq3 = CCSequence.actions(move_ease_out, move_ease_out_back);

            m_grossini.runAction(CCRepeatForever.actionWithAction((CCActionInterval)seq1));
            m_tamara.runAction(CCRepeatForever.actionWithAction((CCActionInterval)seq2));
            m_kathia.runAction(CCRepeatForever.actionWithAction((CCActionInterval)seq3));
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        void HandleMoveCircle(CCTouch touch)
        {
            const float        timeToTake = 1.5f;      // in seconds
            CCFiniteTimeAction coreAction = null;

            // By default all actions will be added directly to the
            // root node - it has values for Position, Scale, and Rotation.
            CCNode nodeToAddTo = drawNodeRoot;

            switch (VariableOptions [currentVariableIndex])
            {
            case "Position":
                coreAction = new CCMoveTo(timeToTake, touch.Location);
                break;

            case "Scale":
                var distance     = CCPoint.Distance(touch.Location, drawNodeRoot.Position);
                var desiredScale = distance / DefaultCircleRadius;
                coreAction = new CCScaleTo(timeToTake, desiredScale);
                break;

            case "Rotation":
                float differenceY = touch.Location.Y - drawNodeRoot.PositionY;
                float differenceX = touch.Location.X - drawNodeRoot.PositionX;

                float angleInDegrees = -1 * CCMathHelper.ToDegrees(
                    (float)Math.Atan2(differenceY, differenceX));

                coreAction = new CCRotateTo(timeToTake, angleInDegrees);

                break;

            case "LineWidth":
                coreAction = new LineWidthAction(timeToTake, touch.Location.X / 40f);
                // The LineWidthAction is a special action designed to work only on
                // LineNode instances, so we have to set the nodeToAddTo to the lineNode:
                nodeToAddTo = lineNode;
                break;
            }

            CCAction easing = null;

            switch (EasingOptions [currentEasingIndex])
            {
            case "CCEaseBack":
                if (currentInOutIndex == 0)
                {
                    easing = new CCEaseBackOut(coreAction);
                }
                else if (currentInOutIndex == 1)
                {
                    easing = new CCEaseBackIn(coreAction);
                }
                else
                {
                    easing = new CCEaseBackInOut(coreAction);
                }

                break;

            case "CCEaseBounce":
                if (currentInOutIndex == 0)
                {
                    easing = new CCEaseBounceOut(coreAction);
                }
                else if (currentInOutIndex == 1)
                {
                    easing = new CCEaseBounceIn(coreAction);
                }
                else
                {
                    easing = new CCEaseBounceInOut(coreAction);
                }

                break;

            case "CCEaseElastic":
                if (currentInOutIndex == 0)
                {
                    easing = new CCEaseElasticOut(coreAction);
                }
                else if (currentInOutIndex == 1)
                {
                    easing = new CCEaseElasticIn(coreAction);
                }
                else
                {
                    easing = new CCEaseElasticInOut(coreAction);
                }

                break;

            case "CCEaseExponential":
                if (currentInOutIndex == 0)
                {
                    easing = new CCEaseExponentialOut(coreAction);
                }
                else if (currentInOutIndex == 1)
                {
                    easing = new CCEaseExponentialIn(coreAction);
                }
                else
                {
                    easing = new CCEaseExponentialInOut(coreAction);
                }

                break;

            case "CCEaseSine":
                if (currentInOutIndex == 0)
                {
                    easing = new CCEaseSineOut(coreAction);
                }
                else if (currentInOutIndex == 1)
                {
                    easing = new CCEaseSineIn(coreAction);
                }
                else
                {
                    easing = new CCEaseSineInOut(coreAction);
                }

                break;
            }

            nodeToAddTo.AddAction(easing ?? coreAction);
        }
Ejemplo n.º 7
0
        private void HandleMoveCircle(CCTouch touch)
        {
            const float        timeToTake = 1.5f;      // in seconds
            CCFiniteTimeAction coreAction = null;

            CCNode nodeToAddTo = drawNodeRoot;

            switch (VariableOptions [currentVariableIndex])
            {
            case "Position":
                coreAction = new CCMoveTo(timeToTake, touch.Location);

                break;

            case "Scale":
                coreAction = new CCScaleTo(timeToTake, touch.Location.X / 100.0f);

                break;

            case "Rotation":
                coreAction = new CCRotateTo(timeToTake, (touch.Location.X / 3) % 360);
                break;

            case "LineWidth":
                coreAction  = new LineWidthAction(timeToTake, touch.Location.X / 40.0f);
                nodeToAddTo = lineNode;
                break;
            }

            CCAction easing = null;

            switch (EasingOptions [currentEasingIndex])
            {
            case "<None>":
                // no easing, do nothing, it will be handled below
                break;

            case "CCEaseBack":
                if (currentInOutIndex == 0)
                {
                    easing = new CCEaseBackOut(coreAction);
                }
                else if (currentInOutIndex == 1)
                {
                    easing = new CCEaseBackIn(coreAction);
                }
                else
                {
                    easing = new CCEaseBackInOut(coreAction);
                }

                break;

            case "CCEaseBounce":
                if (currentInOutIndex == 0)
                {
                    easing = new CCEaseBounceOut(coreAction);
                }
                else if (currentInOutIndex == 1)
                {
                    easing = new CCEaseBounceIn(coreAction);
                }
                else
                {
                    easing = new CCEaseBounceInOut(coreAction);
                }

                break;

            case "CCEaseElastic":
                if (currentInOutIndex == 0)
                {
                    easing = new CCEaseElasticOut(coreAction);
                }
                else if (currentInOutIndex == 1)
                {
                    easing = new CCEaseElasticIn(coreAction);
                }
                else
                {
                    easing = new CCEaseElasticInOut(coreAction);
                }

                break;

            case "CCEaseExponential":

                if (currentInOutIndex == 0)
                {
                    easing = new CCEaseExponentialOut(coreAction);
                }
                else if (currentInOutIndex == 1)
                {
                    easing = new CCEaseExponentialIn(coreAction);
                }
                else
                {
                    easing = new CCEaseExponentialInOut(coreAction);
                }

                break;

            case "CCEaseSine":

                if (currentInOutIndex == 0)
                {
                    easing = new CCEaseSineOut(coreAction);
                }
                else if (currentInOutIndex == 1)
                {
                    easing = new CCEaseSineIn(coreAction);
                }
                else
                {
                    easing = new CCEaseSineInOut(coreAction);
                }

                break;
            }

            if (easing != null)
            {
                nodeToAddTo.AddAction(easing);
            }
            else
            {
                nodeToAddTo.AddAction(coreAction);
            }
        }
Ejemplo n.º 8
0
        private void HandleMoveCircle(CCTouch touch)
        {
            const float        timeToTake = 1.5f;      // in seconds
            CCFiniteTimeAction coreAction = null;

            CCNode nodeToAddTo = drawNodeRoot;

            switch (VariableOptions [currentVariableIndex])
            {
            case "Position":
                coreAction = new CCMoveTo(timeToTake, touch.Location);

                break;

            case "Scale":
                var distance     = CCPoint.Distance(touch.Location, drawNodeRoot.Position);
                var desiredScale = distance / DefaultCircleRadius;
                coreAction = new CCScaleTo(timeToTake, desiredScale);

                break;

            case "Rotation":
                float differenceY = touch.Location.Y - drawNodeRoot.PositionY;
                float differenceX = touch.Location.X - drawNodeRoot.PositionX;

                float angleInDegrees = -1 * CCMathHelper.ToDegrees(
                    (float)System.Math.Atan2(differenceY, differenceX));

                coreAction = new CCRotateTo(timeToTake, angleInDegrees);

                break;

            case "LineWidth":
                coreAction  = new LineWidthAction(timeToTake, touch.Location.X / 40.0f);
                nodeToAddTo = lineNode;
                break;
            }

            CCAction easing = null;

            switch (EasingOptions [currentEasingIndex])
            {
            case "<None>":
                // no easing, do nothing, it will be handled below
                break;

            case "CCEaseBack":
                if (currentInOutIndex == 0)
                {
                    easing = new CCEaseBackOut(coreAction);
                }
                else if (currentInOutIndex == 1)
                {
                    easing = new CCEaseBackIn(coreAction);
                }
                else
                {
                    easing = new CCEaseBackInOut(coreAction);
                }

                break;

            case "CCEaseBounce":
                if (currentInOutIndex == 0)
                {
                    easing = new CCEaseBounceOut(coreAction);
                }
                else if (currentInOutIndex == 1)
                {
                    easing = new CCEaseBounceIn(coreAction);
                }
                else
                {
                    easing = new CCEaseBounceInOut(coreAction);
                }

                break;

            case "CCEaseElastic":
                if (currentInOutIndex == 0)
                {
                    easing = new CCEaseElasticOut(coreAction);
                }
                else if (currentInOutIndex == 1)
                {
                    easing = new CCEaseElasticIn(coreAction);
                }
                else
                {
                    easing = new CCEaseElasticInOut(coreAction);
                }

                break;

            case "CCEaseExponential":
                if (currentInOutIndex == 0)
                {
                    easing = new CCEaseExponentialOut(coreAction);
                }
                else if (currentInOutIndex == 1)
                {
                    easing = new CCEaseExponentialIn(coreAction);
                }
                else
                {
                    easing = new CCEaseExponentialInOut(coreAction);
                }

                break;

            case "CCEaseSine":

                if (currentInOutIndex == 0)
                {
                    easing = new CCEaseSineOut(coreAction);
                }
                else if (currentInOutIndex == 1)
                {
                    easing = new CCEaseSineIn(coreAction);
                }
                else
                {
                    easing = new CCEaseSineInOut(coreAction);
                }

                break;
            }

            if (easing != null)
            {
                nodeToAddTo.AddAction(easing);
            }
            else
            {
                nodeToAddTo.AddAction(coreAction);
            }
        }