예제 #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 CCEaseSineIn(move);
            var move_ease_in_back = move_ease_in.Reverse();

            var move_ease_out      = new CCEaseSineOut(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));
        }
예제 #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 CCEaseSineIn((CCActionInterval)move.Copy());
            var move_ease_in_back = move_ease_in.Reverse();

            var move_ease_out      = new CCEaseSineOut((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));
        }
예제 #3
0
        void MoveClouds()
        {
            if ((windSpeedChanged == true) &&
                (windSpeed > 0))
            {
                CCRepeatForever cloudsAnimation;
                float           targetPositionX      = (windBlowingRight == true ? layerWidth + 350 : -350f);
                CCSequence      cloudsMovingSequence = new CCSequence(new CCMoveBy(0, new CCPoint(0, 0)));
                CCMoveTo        moveAcrossTo         = new CCMoveTo(windSpeed * 3f, new CCPoint(targetPositionX, cloudsParallax.PositionY));
                CCEaseSineIn    easeInAcrossTo       = new CCEaseSineIn(moveAcrossTo);

                cloudsMovingSequence = new CCSequence(moveAcrossTo,
                                                      new CCCallFunc(() => cloudsParallax.PositionX = (windBlowingRight == true ? -350f :
                                                                                                       layerWidth + 350)));
                cloudsAnimation = new CCRepeatForever(cloudsMovingSequence);

                cloudsParallax.StopAllActions();
                cloudsParallax.RunActions(easeInAcrossTo, cloudsAnimation);
            }
            else if (windSpeed < float.Epsilon)
            {
                float         targetPositionX = (windBlowingRight == true ? previousWindSpeed * 7 : previousWindSpeed * -7);
                CCEaseSineOut easeOutBy       = new CCEaseSineOut(new CCMoveBy(previousWindSpeed * 1.2f, new CCPoint(targetPositionX, 0)));

                cloudsParallax.StopAllActions();
                cloudsParallax.RunAction(easeOutBy);
            }
        }
예제 #4
0
        void MoveBoat(bool ignoreWindspeedChange)
        {
            if ((windSpeedChanged == true) ||
                (ignoreWindspeedChange == true))
            {
                CCRepeatForever boatMovingAnimation;
                CCSequence      boatMovingSequence;

                if (windSpeed > 0)
                {
                    float      targetPositionX = (windBlowingRight == true ? layerWidth + boatSprite.ContentSize.Width : -boatSprite.ContentSize.Width);
                    CCMoveTo   moveAcrossTo    = new CCMoveTo(windSpeed * 1.4f, new CCPoint(targetPositionX, boatSprite.PositionY));
                    CCCallFunc resetPositionX  = new CCCallFunc(() => boatSprite.PositionX = (windBlowingRight == true ? -boatSprite.ContentSize.Width :
                                                                                              layerWidth + boatSprite.ContentSize.Width));
                    CCEaseSineIn easeInAcrossTo = new CCEaseSineIn(moveAcrossTo);

                    previousWindSpeed   = windSpeed * 1.4f;
                    boatMovingSequence  = new CCSequence(resetPositionX, moveAcrossTo);
                    boatMovingAnimation = new CCRepeatForever(boatMovingSequence);

                    boatSprite.StopAllActions();
                    boatSprite.RunActions(easeInAcrossTo, boatMovingAnimation);
                }
                else if (previousWindSpeed > 0)
                {
                    float         targetPositionX = (windBlowingRight == true ? previousWindSpeed * 7 : previousWindSpeed * -7);
                    CCEaseSineOut easeOutBy       = new CCEaseSineOut(new CCMoveBy(previousWindSpeed * 1.2f, new CCPoint(targetPositionX, 0)));
                    CCEaseSineOut easeOutSlowerBy = new CCEaseSineOut(new CCMoveBy(previousWindSpeed * 1.4f, new CCPoint(targetPositionX, 0)));
                    CCEaseSineIn  easeInTo        = new CCEaseSineIn(new CCMoveTo(0.5f, new CCPoint(boatSprite.PositionX, oceanSprite.PositionY +
                                                                                                    boatSprite.ContentSize.Height / 2 - 3)));
                    CCCallFunc resetBoatPositionX = new CCCallFunc(() =>
                    {
                        if ((windBlowingRight == true) &&
                            (boatSprite.PositionX >= layerWidth + boatSprite.ContentSize.Width))
                        {
                            boatSprite.PositionX = -boatSprite.ContentSize.Width;
                        }
                        else if ((windBlowingRight == false) &&
                                 (boatSprite.PositionX <= -boatSprite.ContentSize.Width))
                        {
                            boatSprite.PositionX = layerWidth + boatSprite.ContentSize.Width;
                        }
                    });

                    boatMovingSequence = new CCSequence(easeOutBy, resetBoatPositionX, easeOutSlowerBy, easeInTo, boatAnimation);

                    boatSprite.StopAllActions();
                    boatSprite.RunAction(boatMovingSequence);
                }
            }
        }
예제 #5
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      = CCEaseSineIn.actionWithAction((CCActionInterval)(move.copy()));
            CCActionInterval move_ease_in_back = move_ease_in.reverse() as CCActionInterval;

            CCActionInterval move_ease_out      = CCEaseSineOut.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));
        }
예제 #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);
        }
예제 #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);
            }
        }
예제 #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);
            }
        }