Exemple #1
0
        public override void OnEnter()
        {

            base.OnEnter();

            CCSize windowSize = Layer.VisibleBoundsWorldspace.Size;

            CenterSprites(2);

            //
            // sprite 1 (By)
            //
            // startPosition can be any coordinate, but since the movement
            // is relative to the Catmull Rom curve, it is better to start with (0,0).
            //

            Tamara.Position = new CCPoint(50, 50);

            pointArray = new List<CCPoint>();

            pointArray.Add(new CCPoint(0, 0));
            pointArray.Add(new CCPoint(80, 80));
            pointArray.Add(new CCPoint(windowSize.Width - 80, 80));
            pointArray.Add(new CCPoint(windowSize.Width - 80, windowSize.Height - 80));
            pointArray.Add(new CCPoint(80, windowSize.Height - 80));
            pointArray.Add(new CCPoint(80, 80));
            pointArray.Add(new CCPoint(windowSize.Width / 2, windowSize.Height / 2));

            var action = new CCCatmullRomBy(3, pointArray);
            var reverse = action.Reverse();

            var seq = new CCSequence(action, reverse);

            Tamara.RunAction(seq);

            Tamara.RunAction(
                new CCRepeatForever(
                    new CCSequence(
                        new CCMoveBy(0.05f, new CCPoint(10, 0)),
                        new CCMoveBy(0.05f, new CCPoint(-10, 0))
                    )
                )
            );

            //
            // sprite 2 (To)
            //
            // The startPosition is not important here, because it uses a "To" action.
            // The initial position will be the 1st point of the Catmull Rom path
            //

            pointArray2 = new List<CCPoint>();

            pointArray2.Add(new CCPoint(windowSize.Width / 2, 30));
            pointArray2.Add(new CCPoint(windowSize.Width - 80, 30));
            pointArray2.Add(new CCPoint(windowSize.Width - 80, windowSize.Height - 80));
            pointArray2.Add(new CCPoint(windowSize.Width / 2, windowSize.Height - 80));
            pointArray2.Add(new CCPoint(windowSize.Width / 2, 30));


            var action2 = new CCCatmullRomTo(3, pointArray2);
            var reverse2 = action2.Reverse();

            var seq2 = new CCSequence(action2, reverse2);

            Kathia.RunAction(seq2);

            Kathia.RunAction(
                new CCRepeatForever(
                    new CCSequence(
                        new CCMoveBy(0.05f, new CCPoint(10, 0)),
                        new CCMoveBy(0.05f, new CCPoint(-10, 0))
                    )
                )
            );

        }
Exemple #2
0
        public override void OnEnter()
        {
            base.OnEnter(); 

            CCSize windowSize = Layer.VisibleBoundsWorldspace.Size;

            CenterSprites(2);

            Tamara.Position = new CCPoint(50, 50);

            pointList.Clear();

            pointList.Add(new CCPoint(0, 0));
            pointList.Add(new CCPoint(80, 80));
            pointList.Add(new CCPoint(windowSize.Width - 80, 80));
            pointList.Add(new CCPoint(windowSize.Width - 80, windowSize.Height - 80));
            pointList.Add(new CCPoint(80, windowSize.Height - 80));
            pointList.Add(new CCPoint(80, 80));
            pointList.Add(new CCPoint(windowSize.Width / 2, windowSize.Height / 2));

            var action = new CCCatmullRomBy (3, pointList);
            var reverse = action.Reverse();
            CCFiniteTimeAction seq = new CCSequence(action, reverse);

            pointList2.Clear();

            pointList2.Add(new CCPoint(windowSize.Width / 2, 30));
            pointList2.Add(new CCPoint(windowSize.Width - 80, 30));
            pointList2.Add(new CCPoint(windowSize.Width - 80, windowSize.Height - 80));
            pointList2.Add(new CCPoint(windowSize.Width / 2, windowSize.Height - 80));
            pointList2.Add(new CCPoint(windowSize.Width / 2, 30));

            var action2 = new CCCatmullRomTo (3, pointList2);
            var reverse2 = action2.Reverse();

            CCFiniteTimeAction seq2 = new CCSequence(action2, reverse2);

            Tamara.RunAction(seq);
            Kathia.RunAction(seq2);
        }