Ejemplo n.º 1
0
        /** creates an action with a Cardinal Spline array of points and tension */
        public static CCCardinalSplineBy create(float duration, CCPointArray points, float tension)
        {
            CCCardinalSplineBy ret = new CCCardinalSplineBy();

            ret.initWithDuration(duration, points, tension);
            return(ret);
        }
Ejemplo n.º 2
0
        public virtual new CCActionInterval reverse()
        {
            CCPointArray cCPointArray        = this.m_pPoints.copy();
            CCPoint      controlPointAtIndex = cCPointArray.getControlPointAtIndex(0);

            for (int i = 1; i < cCPointArray.count(); i++)
            {
                CCPoint cCPoint = cCPointArray.getControlPointAtIndex(i);
                cCPointArray.replaceControlPoint(cCPoint.Sub(controlPointAtIndex), i);
                controlPointAtIndex = cCPoint;
            }
            CCPointArray cCPointArray1 = cCPointArray.reverse();

            controlPointAtIndex = cCPointArray1.getControlPointAtIndex(cCPointArray1.count() - 1);
            cCPointArray1.removeControlPointAtIndex(cCPointArray1.count() - 1);
            controlPointAtIndex = controlPointAtIndex.Neg();
            cCPointArray1.insertControlPoint(controlPointAtIndex, 0);
            for (int j = 1; j < cCPointArray1.count(); j++)
            {
                CCPoint controlPointAtIndex1 = cCPointArray1.getControlPointAtIndex(j);
                CCPoint cCPoint1             = controlPointAtIndex1.Neg().Add(controlPointAtIndex);
                cCPointArray1.replaceControlPoint(cCPoint1, j);
                controlPointAtIndex = cCPoint1;
            }
            return(CCCardinalSplineBy.create(this.m_fDuration, cCPointArray1, this.m_fTension));
        }
Ejemplo n.º 3
0
        public virtual CCActionInterval reverse()
        {
            CCPointArray copyConfig = (CCPointArray)m_pPoints.copy();

            //
            // convert "absolutes" to "diffs"
            //
            CCPoint p = copyConfig.getControlPointAtIndex(0);

            for (int i = 1; i < copyConfig.count(); ++i)
            {
                CCPoint current = copyConfig.getControlPointAtIndex(i);
                CCPoint diff    = current - p;
                copyConfig.replaceControlPoint(diff, i);

                p = current;
            }


            // convert to "diffs" to "reverse absolute"

            CCPointArray pReverse = copyConfig.reverse();

            // 1st element (which should be 0,0) should be here too

            p = pReverse.getControlPointAtIndex(pReverse.count() - 1);
            pReverse.removeControlPointAtIndex(pReverse.count() - 1);

            p = -p;
            pReverse.insertControlPoint(p, 0);

            for (int i = 1; i < pReverse.count(); ++i)
            {
                CCPoint current = pReverse.getControlPointAtIndex(i);
                current = -current;
                CCPoint abs = current + p;
                pReverse.replaceControlPoint(abs, i);

                p = abs;
            }

            return(CCCardinalSplineBy.create(Duration, pReverse, m_fTension));
        }
Ejemplo n.º 4
0
 /** creates an action with a Cardinal Spline array of points and tension */
 public static CCCardinalSplineBy create(float duration, CCPointArray points, float tension)
 {
     CCCardinalSplineBy ret = new CCCardinalSplineBy();
     ret.initWithDuration(duration, points, tension);
     return ret;
 }
Ejemplo n.º 5
0
        public override void OnEnter()
        {
            base.OnEnter();

            centerSprites(2);

            var s = CCDirector.SharedDirector.WinSize;

            m_pArray.Add(new CCPoint(0, 0));
            m_pArray.Add(new CCPoint(s.Width / 2 - 30, 0));
            m_pArray.Add(new CCPoint(s.Width / 2 - 30, s.Height - 80));
            m_pArray.Add(new CCPoint(0, s.Height - 80));
            m_pArray.Add(new CCPoint(0, 0));

            //
            // sprite 1 (By)
            //
            // Spline with no tension (tension==0)
            //

            var action = new CCCardinalSplineBy (3, m_pArray, 0);
            var reverse = action.Reverse();

            var seq = CCSequence.FromActions(action, reverse);

            m_tamara.Position = new CCPoint(50, 50);
            m_tamara.RunAction(seq);

            //
            // sprite 2 (By)
            //
            // Spline with high tension (tension==1)
            //

            var action2 = new CCCardinalSplineBy (3, m_pArray, 1);
            var reverse2 = action2.Reverse();

            var seq2 = CCSequence.FromActions(action2, reverse2);

            m_kathia.SetPosition(s.Width / 2, 50);
            m_kathia.RunAction(seq2);
        }
Ejemplo n.º 6
0
 /** creates an action with a Cardinal Spline array of points and tension
  * @deprecated: This interface will be deprecated sooner or later.
  */
 public static CCCardinalSplineBy actionWithDuration(float duration, CCPointArray points, float tension)
 {
     return(CCCardinalSplineBy.create(duration, points, tension));
 }