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

            Color = CCColor3B.Blue;
            Opacity = 255;

            // Make sure we set the Opacity to cascade or fadein action will not work correctly.
            Target1.IsOpacityCascaded = true;
            Target2.IsOpacityCascaded = true;

            // Define actions
            var moveUp = new CCMoveBy(1.0f, new CCPoint(0.0f, 50.0f));
            var moveDown = moveUp.Reverse();

            // A CCSequence action runs the list of actions in ... sequence!
            var moveSeq = new CCSequence(new CCEaseBackInOut(moveUp), new CCEaseBackInOut(moveDown));

            var repeatedAction = new CCRepeatForever(moveSeq);

            // A CCSpawn action runs the list of actions concurrently
            var dreamAction = new CCSpawn(new CCFadeIn(5.0f), new CCWaves(5.0f, new CCGridSize(10, 20), 5, 20, true, false));


            Target1.RunActions(dreamAction, repeatedAction);

            Target2.RunActions(dreamAction, new CCDelayTime(0.5f), repeatedAction);

            // moving background. Testing issue #244
            var move = new CCMoveBy (3, new CCPoint(200, 0));

            bgNode.RepeatForever(move, move.Reverse());
        }
Exemplo n.º 2
0
        public GameLayer()
            : base(CCColor4B.Blue, CCColor4B.AliceBlue)
        {
            // Set the layer gradient direction
            this.Vector = new CCPoint(0.5f, 0.5f);

            // Create and add sprites
            monkeySprite1 = new CCSprite("monkey");
            AddChild(monkeySprite1, 1);

            monkeySprite2 = new CCSprite("monkey");
            AddChild(monkeySprite2, 1);

            // Define actions
            var moveUp = new CCMoveBy(1.0f, new CCPoint(0.0f, 50.0f));
            var moveDown = moveUp.Reverse();

            // A CCSequence action runs the list of actions in ... sequence!
            CCSequence moveSeq = new CCSequence(new CCEaseBackInOut(moveUp), new CCEaseBackInOut(moveDown));

            repeatedAction = new CCRepeatForever(moveSeq);

            // A CCSpawn action runs the list of actions concurrently
            dreamAction = new CCSpawn(new CCFadeIn(5.0f), new CCWaves(5.0f, new CCGridSize(10, 20), 4, 4));

            // Schedule for method to be called every 0.1s
            Schedule(UpdateLayerGradient, 0.1f);
        }
Exemplo n.º 3
0
        public CCSpawn (params CCFiniteTimeAction[] actions)
        {
            CCFiniteTimeAction prev = actions [0];
            CCFiniteTimeAction next = null;

            if (actions.Length == 1)
            {
                next = new CCExtraAction ();
            }
            else
            {
                // We create a nested set of CCSpawnActions out of all of the actions
                for (int i = 1; i < actions.Length - 1; i++)
                {
                    prev = new CCSpawn (prev, actions [i]);
                }

                next = actions [actions.Length - 1];
            }

            // Can't call base(duration) because we need to determine max duration
            // Instead call base's init method here
            if (prev != null && next != null)
            {
                Duration = Math.Max (prev.Duration, next.Duration);
                InitCCSpawn (prev, next);
            }
        }
        void OnTouchesEnded(List <CCTouch> touches, CCEvent touchEvent)
        {
            if (touches.Count > 0)
            {
                // Establezco los valores iniciales por si se ejecuta mas de una vez!
                label.Scale    = 1;
                label.Rotation = 0;

                float duracion = 3; // variable que indica cuanto tiempo dura la animacion.

                // Animacion que hace crecer mi nodo por el tiempo definido, a un Scale de 3 veces su tamaño original.
                CCScaleBy escalar = new CCScaleBy(duracion, 3);

                // Animacion que hace rotar mi nodo por el tiempo definido, a un angulo de 360 grados.
                CCRotateBy rotacion = new CCRotateBy(duracion, 360);

                // El uso de global permite que mi compilador no se confunda entre el namespace de mi proyecto y el de CocosSharp
                // Creo el objeto CCSpawn, pasandole las animaciones que quiero ejecutar.
                global::CocosSharp.CCSpawn spawn = new CocosSharp.CCSpawn(escalar, rotacion);

                //Ejecuto las animaciones en el label.
                label.RunAction(spawn);
            }
        }
Exemplo n.º 5
0
 public ActionSpawn()
 {
     action = new CCSpawn(new CCJumpBy (2, new CCPoint(300, 0), 50, 4), new CCRotateBy (2, 720));
 }
Exemplo n.º 6
0
        void OnDeleteBackward (object sender, CCIMEKeybardEventArgs e)
        {
            var focusedTextField = sender as CCTextField;

            if (focusedTextField == null || string.IsNullOrEmpty(focusedTextField.Text))
            {
                e.Cancel = true;
                return;
            }

            // Just cancel this if we would backspace over the PlaceHolderText as it would just be
            // replaced anyway and the Action below should not be executed.
            var delText = focusedTextField.Text;
            if (delText == focusedTextField.PlaceHolderText)
            {
                e.Cancel = true;
                return;
            }

            delText = delText.Substring(delText.Length - 1);

            // create a delete text sprite and do some action
            var label = new CCLabel(delText, TextInputTestScene.FONT_NAME, TextInputTestScene.FONT_SIZE + 3, CCLabelFormat.SpriteFont);
            this.AddChild(label);

            // move the sprite to fly out
            CCPoint beginPos = focusedTextField.Position;
            CCSize textfieldSize = focusedTextField.ContentSize;
            CCSize labelSize = label.ContentSize;
            beginPos.X += (textfieldSize.Width - labelSize.Width) / 2.0f;

            var nextRandom = (float)CCRandom.Next(RANDOM_MAX);

            CCSize winSize = VisibleBoundsWorldspace.Size;
            CCPoint endPos = new CCPoint(-winSize.Width / 4.0f, winSize.Height * (0.5f + nextRandom / (2.0f * RANDOM_MAX)));

            float duration = 1;
            float rotateDuration = 0.2f;
            int repeatTime = 5;
            label.Position = beginPos;

            var delAction = new CCSpawn(new CCMoveTo(duration, endPos),
                new CCRepeat(
                        new CCRotateBy(rotateDuration, (CCRandom.Next() % 2 > 0) ? 360 : -360),
                        (uint)repeatTime),
                        new CCFadeOut(duration)
                );

            label.RunActionsAsync(delAction, new CCRemoveSelf(true));

        }
Exemplo n.º 7
0
        public CCSpawnState (CCSpawn action, CCNode target)
            : base (action, target)
        { 
            ActionOne = action.ActionOne;
            ActionTwo = action.ActionTwo;

            ActionStateOne = (CCFiniteTimeActionState)ActionOne.StartAction (target);
            ActionStateTwo = (CCFiniteTimeActionState)ActionTwo.StartAction (target);
        }
Exemplo n.º 8
0
        public override void OnEnter()
        {
            base.OnEnter();

            var s = Layer.VisibleBoundsWorldspace.Size;

            // rotate and jump
            var jump1 = new CCJumpBy (4, new CCPoint(-s.Width + 80, 0), 100, 4);
            var jump2 = jump1.Reverse();
            var rot1 = new CCRotateBy (4, 360 * 2);
            var rot2 = rot1.Reverse();

            var seq3_1 = new CCSequence(jump2, jump1);
            var seq3_2 = new CCSequence(rot1, rot2);
            var spawn = new CCSpawn(seq3_1, seq3_2);

            speedAction1 = new CCSpeed(new CCRepeatForever (spawn), 1.0f);
            speedAction2 = new CCSpeed(new CCRepeatForever (spawn), 2.0f);
            speedAction3 = new CCSpeed(new CCRepeatForever (spawn), 0.5f);

            m_grossini.RunAction(speedAction1);
			m_tamara.RunAction(speedAction2);
			m_kathia.RunAction(speedAction3);
        }