예제 #1
0
        public override void ccTouchesEnded(List <CCTouch> touches, CCEvent event_)
        {
            //base.ccTouchesEnded(touches, event_);
            object  it    = touches.First();
            CCTouch touch = (CCTouch)(it);

            CCPoint location          = touch.locationInView(touch.view());
            CCPoint convertedLocation = CCDirector.sharedDirector().convertToGL(location);

            CCNode s = getChildByTag(ClickAndMoveTest.kTagSprite);

            s.stopAllActions();
            s.runAction(CCMoveTo.actionWithDuration(1, new CCPoint(convertedLocation.x, convertedLocation.y)));
            float o  = convertedLocation.x - s.position.x;
            float a  = convertedLocation.y - s.position.y;
            float at = (float)(Math.Atan(o / a) * 57.29577951f);

            if (a < 0)
            {
                if (o < 0)
                {
                    at = 180 + Math.Abs(at);
                }
                else
                {
                    at = 180 - Math.Abs(at);
                }
            }

            s.runAction(CCRotateTo.actionWithDuration(1, at));
        }
예제 #2
0
        public static CCRotateTo actionWithDuration(float duration, float fDeltaAngle)
        {
            CCRotateTo ret = new CCRotateTo();
            ret.initWithDuration(duration, fDeltaAngle);

            return ret;
        }
예제 #3
0
        public override CCObject copyWithZone(CCZone zone)
        {
            CCZone tmpZone = zone;
            CCRotateTo ret = null;

            if (tmpZone != null && tmpZone.m_pCopyObject != null)
            {
                ret = tmpZone.m_pCopyObject as CCRotateTo;
                if (ret == null)
                {
                    return null;
                }
            }
            else
            {
                ret = new CCRotateTo();
                tmpZone = new CCZone(ret);
            }

            base.copyWithZone(tmpZone);

            ret.initWithDuration(Duration, m_fDstAngle);

            return ret;
        }
예제 #4
0
        public override CCObject copyWithZone(CCZone zone)
        {
            CCZone     tmpZone = zone;
            CCRotateTo ret     = null;

            if (tmpZone != null && tmpZone.m_pCopyObject != null)
            {
                ret = tmpZone.m_pCopyObject as CCRotateTo;
                if (ret == null)
                {
                    return(null);
                }
            }
            else
            {
                ret     = new CCRotateTo();
                tmpZone = new CCZone(ret);
            }

            base.copyWithZone(tmpZone);

            ret.initWithDuration(m_fDuration, m_fDstAngle);

            return(ret);
        }
예제 #5
0
        public static CCRotateTo actionWithDuration(float duration, float fDeltaAngle)
        {
            CCRotateTo ret = new CCRotateTo();

            ret.initWithDuration(duration, fDeltaAngle);

            return(ret);
        }
예제 #6
0
        public void StartRotation()
        {
            float angle = (float)(360 / Math.PI * Math.Atan(VelocityX / VelocityY));

            angle += VelocityY < 0 ? 180 : 0;
            Random     random   = new Random();
            float      duration = (float)random.NextDouble() / 2;
            CCRotateTo action   = new CCRotateTo(duration, angle);

            AddAction(action);
        }
예제 #7
0
        public override void OnEnter()
        {
            base.OnEnter();

            centerSprites(2);

            var act1 = new CCRotateTo(1, 90);
            var act2 = new CCRotateTo(1, 0);
            var seq  = (CCSequence.FromActions(act1, act2));
            var rep1 = new CCRepeatForever((CCActionInterval)seq);
            var rep2 = new CCRepeat((CCFiniteTimeAction)(seq.Copy()), 10);

            m_tamara.RunAction(rep1);
            m_kathia.RunAction(rep2);
        }
예제 #8
0
        public override void onEnter()
        {
            base.onEnter();

            centerSprites(2);

            CCActionInterval act1 = CCRotateTo.actionWithDuration(1, 90);
            CCActionInterval act2 = CCRotateTo.actionWithDuration(1, 0);
            CCActionInterval seq  = (CCActionInterval)(CCSequence.actions(act1, act2));
            CCAction         rep1 = CCRepeatForever.actionWithAction(seq);
            CCActionInterval rep2 = CCRepeat.actionWithAction((CCFiniteTimeAction)(seq.copy()), 10);

            m_tamara.runAction(rep1);
            m_kathia.runAction(rep2);
        }
예제 #9
0
        public override void onEnter()
        {
            base.onEnter();

            centerSprites(2);

            CCFiniteTimeAction seq = CCSequence.actions(
                CCRotateTo.actionWithDuration(0.5f, -20),
                CCRotateTo.actionWithDuration(0.5f, 20));

            CCActionInterval rep1 = CCRepeat.actionWithAction(seq, 10);
            CCAction         rep2 = CCRepeatForever.actionWithAction((CCActionInterval)(seq.copy()));

            m_tamara.runAction(rep1);
            m_kathia.runAction(rep2);
        }
예제 #10
0
        public override void OnEnter()
        {
            base.OnEnter();

            m_tamara.RemoveFromParentAndCleanup(true);
            m_grossini.RemoveFromParentAndCleanup(true);
            m_kathia.RemoveFromParentAndCleanup(true);

            // Get window size so that we can center the box layer
            var winSize = CCDirector.SharedDirector.WinSize;

            var boxSize = new CCSize(100.0f, 100.0f);

            var box = new CCLayerColor(new CCColor4B(255, 255, 0, 255));

            box.AnchorPoint = new CCPoint(0, 0);
            box.Position    = new CCPoint(winSize.Center.X - (boxSize.Width / 2), winSize.Center.Y - (boxSize.Height / 2));
            box.ContentSize = boxSize;

            var uL = new CCLayerColor(new CCColor4B(255, 0, 0, 255));

            box.AddChild(uL);
            uL.ContentSize = new CCSize(markrside, markrside);
            uL.Position    = new CCPoint(0.0f, boxSize.Height - markrside);
            uL.AnchorPoint = new CCPoint(0, 0);

            var uR = new CCLayerColor(new CCColor4B(0, 0, 255, 255));

            box.AddChild(uR);
            uR.ContentSize = new CCSize(markrside, markrside);
            uR.Position    = new CCPoint(boxSize.Width - markrside, boxSize.Height - markrside);
            uR.AnchorPoint = new CCPoint(0, 0);
            AddChild(box);

            var actionTo      = new CCSkewTo(2, 0.0f, 2.0f);
            var rotateTo      = new CCRotateTo(2, 61.0f);
            var actionScaleTo = new CCScaleTo(2, -0.44f, 0.47f);

            var actionScaleToBack = new CCScaleTo(2, 1.0f, 1.0f);
            var rotateToBack      = new CCRotateTo(2, 0);
            var actionToBack      = new CCSkewTo(2, 0, 0);

            box.RunAction(CCSequence.FromActions(actionTo, actionToBack));
            box.RunAction(CCSequence.FromActions(rotateTo, rotateToBack));
            box.RunAction(CCSequence.FromActions(actionScaleTo, actionScaleToBack));
        }
예제 #11
0
        public override void onEnter()
        {
            // todo: CCLayerColor hasn't been implemented

            base.onEnter();

            m_tamara.removeFromParentAndCleanup(true);
            m_grossini.removeFromParentAndCleanup(true);
            m_kathia.removeFromParentAndCleanup(true);

            CCSize boxSize = new CCSize(100.0f, 100.0f);

            CCLayerColor box = CCLayerColor.layerWithColor(new ccColor4B(255, 255, 0, 255));

            box.anchorPoint = new CCPoint(0, 0);
            box.position    = new CCPoint(190, 110);
            box.contentSize = boxSize;

            CCLayerColor uL = CCLayerColor.layerWithColor(new ccColor4B(255, 0, 0, 255));

            box.addChild(uL);
            uL.contentSize = new CCSize(markrside, markrside);
            uL.position    = new CCPoint(0.0f, boxSize.height - markrside);
            uL.anchorPoint = new CCPoint(0, 0);

            CCLayerColor uR = CCLayerColor.layerWithColor(new ccColor4B(0, 0, 255, 255));

            box.addChild(uR);
            uR.contentSize = new CCSize(markrside, markrside);
            uR.position    = new CCPoint(boxSize.width - markrside, boxSize.height - markrside);
            uR.anchorPoint = new CCPoint(0, 0);
            addChild(box);

            CCActionInterval actionTo      = CCSkewTo.actionWithDuration(2, 0.0f, 2.0f);
            CCActionInterval rotateTo      = CCRotateTo.actionWithDuration(2, 61.0f);
            CCActionInterval actionScaleTo = CCScaleTo.actionWithDuration(2, -0.44f, 0.47f);

            CCActionInterval actionScaleToBack = CCScaleTo.actionWithDuration(2, 1.0f, 1.0f);
            CCActionInterval rotateToBack      = CCRotateTo.actionWithDuration(2, 0);
            CCActionInterval actionToBack      = CCSkewTo.actionWithDuration(2, 0, 0);

            box.runAction(CCSequence.actions(actionTo, actionToBack));
            box.runAction(CCSequence.actions(rotateTo, rotateToBack));
            box.runAction(CCSequence.actions(actionScaleTo, actionScaleToBack));
        }
예제 #12
0
        public void HandleInput(CCPoint touchPoint)
        {
            desiredLocation = touchPoint;

            float differenceY = touchPoint.Y - this.PositionY;
            float differenceX = touchPoint.X - this.PositionX;

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

            var rotateAction = new CCRotateTo(0.3f, angleInDegrees);

            this.AddAction(rotateAction);

            var      moveAction   = new CCMoveTo(1f, touchPoint);
            CCAction easingAction = new CCEaseSineInOut(moveAction);

            this.AddAction(easingAction);
        }
예제 #13
0
        public override void onEnter()
        {
            base.onEnter();

            centerSprites(3);

            CCActionInterval actionTo  = CCRotateTo.actionWithDuration(2, 45);
            CCActionInterval actionTo2 = CCRotateTo.actionWithDuration(2, -45);
            CCActionInterval actionTo0 = CCRotateTo.actionWithDuration(2, 0);

            m_tamara.runAction(CCSequence.actions(actionTo, actionTo0));

            CCActionInterval   actionBy     = CCRotateBy.actionWithDuration(2, 360);
            CCFiniteTimeAction actionByBack = actionBy.reverse();

            m_grossini.runAction(CCSequence.actions(actionBy, actionByBack));

            // m_kathia->runAction( CCSequence::actions(actionTo2, actionTo0->copy()->autorelease(), NULL));
            m_kathia.runAction(CCSequence.actions(actionTo2, actionTo0));
        }
예제 #14
0
        public override void OnEnter()
        {
            base.OnEnter();

            centerSprites(3);

            var actionTo  = new CCRotateTo(2, 45);
            var actionTo2 = new CCRotateTo(2, -45);
            var actionTo0 = new CCRotateTo(2, 0);

            m_tamara.RunAction(CCSequence.FromActions(actionTo, actionTo0));

            var actionBy     = new CCRotateBy(2, 360);
            var actionByBack = actionBy.Reverse();

            m_grossini.RunAction(CCSequence.FromActions(actionBy, actionByBack));

            // m_kathia->runAction( CCSequence::actions(actionTo2, actionTo0->copy()->autorelease(), NULL));
            m_kathia.RunAction(CCSequence.FromActions(actionTo2, (CCActionInterval)actionTo0.Copy()));
        }
예제 #15
0
 protected CCRotateTo(CCRotateTo rotateTo)
     : base(rotateTo)
 {
     InitWithDuration(rotateTo.m_fDuration, rotateTo.m_fDstAngle);
 }
예제 #16
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);
            }
        }
예제 #17
0
 protected CCRotateTo(CCRotateTo rotateTo) : base(rotateTo)
 {
     InitWithDuration(rotateTo.m_fDuration, rotateTo.m_fDstAngle);
 }
예제 #18
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);
        }
예제 #19
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);
            }
        }