Exemplo n.º 1
0
        /**
         * Sets a new content offset. It ignores max/min offset. It just sets what's given. (just like UIKit's UIScrollView)
         * You can override the animation duration with this method.
         *
         * @param offset new offset
         * @param animation duration
         */

        public void SetContentOffsetInDuration(CCPoint offset, float dt)
        {
            CCMoveTo    scroll = new CCMoveTo(dt, offset);
            CCCallFuncN expire = new CCCallFuncN(StoppedAnimatedScroll);

            m_pContainer.RunAction(CCSequence.FromActions(scroll, expire));
            Schedule(PerformedAnimatedScroll);
        }
Exemplo n.º 2
0
        public override void OnEnter()
        {
            base.OnEnter();

            centerSprites(3);

            var s = CCDirector.SharedDirector.WinSize;

            var actionTo = new CCMoveTo (2, new CCPoint(s.Width - 40, s.Height - 40));
            var actionBy = new CCMoveBy (2, new CCPoint(80, 80));
            var actionByBack = actionBy.Reverse();

            m_tamara.RunAction(new CCSequence(actionTo, new CCCallFunc(new Action(() =>
            {
                if ((m_tamara.Position.X != s.Width - 40) || (m_tamara.Position.Y != s.Height - 40))
                {
                    CCLog.Log("ERROR: MoveTo on tamara has failed. Position of tamara = {0}, expected = {1},{2}", m_tamara.Position, s.Width - 40, s.Height - 40);
                }
            }))));
            m_grossini.RunAction(new CCSequence(actionBy, actionByBack));
            m_kathia.RunAction(new CCSequence(new CCMoveTo(1, new CCPoint(40, 40)), new CCCallFunc(new Action(() =>
            {
                if (m_kathia.Position.X != 40 || m_kathia.Position.Y != 40)
                {
                    CCLog.Log("ERROR: MoveTo on kathia failed. Expected 40,40 but ended at {0}", m_kathia.Position);
                }
            }))));
        }
Exemplo n.º 3
0
        public override void OnEnter()
        {
            base.OnEnter();

            centerSprites(3);

            var s = CCDirector.SharedDirector.WinSize;

            var actionTo = new CCMoveTo(2, new CCPoint(s.Width - 40, s.Height - 40));
            var actionBy = new CCMoveBy(2, new CCPoint(80, 80));
            var actionByBack = actionBy.Reverse();

            m_tamara.RunAction(new CCSequence(new CCParallel(actionTo, new CCFadeIn(2)), actionBy, actionByBack));
            m_grossini.RunAction(new CCSequence(actionBy, new CCParallel(actionByBack, new CCScaleTo(2, 0.25f))));
            m_kathia.RunAction(new CCMoveTo(1, new CCPoint(40, 40)));
        }
Exemplo n.º 4
0
        public override void OnEnter()
        {
            base.OnEnter();

            this.TouchEnabled = true;

            CCSize s = CCDirector.SharedDirector.WinSize;

            CCLayerColor layer1 = new CCLayerColor(new CCColor4B(0xFF, 0xFF, 0x00, 0x80), s.Width * 0.75f, s.Height * 0.75f);
            layer1.IgnoreAnchorPointForPosition = false;
            layer1.Position = (new CCPoint(s.Width / 2, s.Height / 2));
            layer1.ChildClippingMode = CCClipMode.Bounds;
            AddChild(layer1, 1);

            s = layer1.ContentSize;

            m_pInnerLayer = new CCLayerColor(new CCColor4B(0xFF, 0x00, 0x00, 0x80), s.Width * 0.5f, s.Height * 0.5f);
            m_pInnerLayer.IgnoreAnchorPointForPosition = false;
            m_pInnerLayer.Position = (new CCPoint(s.Width / 2, s.Height / 2));
            m_pInnerLayer.ChildClippingMode = CCClipMode.Bounds;
            
            layer1.AddChild(m_pInnerLayer, 1);
            
            //
            // Add two labels using BM label class
            // CCLabelBMFont
            CCLabelBMFont label1 = new CCLabelBMFont("LABEL1", "fonts/konqa32.fnt");
            label1.Position = new CCPoint(m_pInnerLayer.ContentSize.Width, m_pInnerLayer.ContentSize.Height * 0.75f);
            m_pInnerLayer.AddChild(label1);
            
            CCLabelBMFont label2 = new CCLabelBMFont("LABEL2", "fonts/konqa32.fnt");
            label2.Position = new CCPoint(0, m_pInnerLayer.ContentSize.Height * 0.25f);
            m_pInnerLayer.AddChild(label2);

            float runTime = 12f;

            CCScaleTo scaleTo2 = new CCScaleTo(runTime * 0.25f, 3.0f);
            CCScaleTo scaleTo3 = new CCScaleTo(runTime * 0.25f, 1.0f);

            CCFiniteTimeAction seq = new CCRepeatForever(
                new CCSequence(scaleTo2, scaleTo3)
                );

            m_pInnerLayer.RunAction(seq);

            CCSize size = CCDirector.SharedDirector.WinSize;

            var move1 = new CCMoveTo(2, new CCPoint(size.Width / 2, size.Height));
            var move2 = new CCMoveTo(2, new CCPoint(size.Width, size.Height / 2));
            var move3 = new CCMoveTo(2, new CCPoint(size.Width / 2, 0));
            var move4 = new CCMoveTo(2, new CCPoint(0, size.Height / 2));

            layer1.RunAction(new CCRepeatForever(new CCSequence(move1, move2, move3, move4)));

        }
Exemplo n.º 5
0
        /**
     * Sets a new content offset. It ignores max/min offset. It just sets what's given. (just like UIKit's UIScrollView)
     * You can override the animation duration with this method.
     *
     * @param offset new offset
     * @param animation duration
     */

        public void SetContentOffsetInDuration(CCPoint offset, float dt)
        {
            CCMoveTo scroll = new CCMoveTo (dt, offset);
            CCCallFuncN expire = new CCCallFuncN(StoppedAnimatedScroll);
            _container.RunAction(new CCSequence(scroll, expire));
            Schedule(PerformedAnimatedScroll);
        }
        private void addRemoteBanana(float x)
        {
            Console.WriteLine ("addRemoteBanana");
            var banana = new CCSprite ("BananaRemote");

            banana.Position = new CCPoint (x, banana.ContentSize.Height / 2);

            AddChild (banana);

            var moveBanana = new CCMoveTo (5.0f, new CCPoint (banana.Position.X, CCDirector.SharedDirector.WinSize.Height));

            var moveBananaComplete = new CCCallFuncN ((node) => {
                node.RemoveFromParentAndCleanup (true);
            });

            var moveBananaSequence = new CCSequence (moveBanana, moveBananaComplete);

            banana.RunAction (moveBananaSequence);
        }
        private void moveRemoteMonkey(float x)
        {
            Console.WriteLine ("moveRemoteMonkey");
            var location = new CCPoint ();
            location.X = x;
            location.Y = remoteMonkey.PositionY;
            float ds = CCPoint.Distance (remoteMonkey.Position, location);

            float dt = ds / MONKEY_SPEED;

            var moveMonkey = new CCMoveTo (dt, location);
            remoteMonkey.RunAction (moveMonkey);
        }
        CCSprite AddLocalBanana()
        {
            var banana = new CCSprite ("BananaLocal");
            banana.Tag = 0;
            double rnd = new Random ().NextDouble ();
            double randomX = (rnd > 0)
                ? rnd * CCDirector.SharedDirector.WinSize.Width - banana.ContentSize.Width / 2
                : banana.ContentSize.Width / 2;

            banana.Position = new CCPoint ((float)randomX, CCDirector.SharedDirector.WinSize.Height - banana.ContentSize.Height / 2);

            byte[] message = buildBananaMessage ((float)randomX);
            sendWarpUpdate (message);

            AddChild (banana);

            var moveBanana = new CCMoveTo (5.0f, new CCPoint (banana.Position.X, 0));

            var moveBananaComplete = new CCCallFuncN ((node) => {
                node.RemoveFromParentAndCleanup (true);
                localBananas.Remove(banana);
            });

            var moveBananaSequence = new CCSequence (moveBanana, moveBananaComplete);

            banana.RunAction (moveBananaSequence);

            return banana;
        }
        public override void TouchesEnded(List<CCTouch> touches)
        {
            base.TouchesEnded (touches);

            var location = new CCPoint ();
            location.X = touches [0].Location.X;
            location.Y = localMonkey.PositionY;
            float ds = CCPoint.Distance (localMonkey.Position, location);

            float dt = ds / MONKEY_SPEED;

            var moveMonkey = new CCMoveTo (dt, location);
            localMonkey.RunAction (moveMonkey);

            byte[] message = buildMonkeyMessage (location.X);
            sendWarpUpdate (message);
        }
 /// <summary>
 /// Moves the active sprite to a specific location on the screen.
 /// </summary>
 /// <param name="position">A CCPoint object that contains the location where the sprite should be moved.</param>
 internal void MoveTo(CCPoint position)
 {
     // Make sure we have a sprite to run the action
     if (_activeSprite != null)
     {
         // Move the sprite to the position
         CCActionInterval action = new CCMoveTo(1, position);
         _activeSprite.RunAction(action);
     }
 }
Exemplo n.º 11
0
        void ShowPointsWithImagesForValue(int pointValue, CCPoint positionToShowScore)
        {
            CCSprite scoreLabel;

            if (pointValue == 100) {

                scoreLabel = new CCSprite ("100points.png");
            }
            else if (pointValue == 500) {

                scoreLabel = new CCSprite ("500points.png");
            }
            else if (pointValue == 1000) {

                scoreLabel = new CCSprite ("1000points.png");
            }
            else if (pointValue == 5000) {

                scoreLabel = new CCSprite ("5000points.png");
            }
            else if (pointValue == 10000) {

                scoreLabel = new CCSprite ("10000points.png");
            }
            else { //default

                scoreLabel = new CCSprite ("100points.png");

            }

            AddChild(scoreLabel, Constants.DepthPointScore);
            scoreLabel.Position = positionToShowScore;

            CCMoveTo moveAction = new CCMoveTo(1.0f, new CCPoint ( scoreLabel.Position.X  , scoreLabel.Position.Y + 25 ));

            scoreLabel.RunAction(moveAction);

            CCSequence seq = new CCSequence(
                               new CCFadeTo(1.5f, 20),
                               new CCCallFuncN(RemoveThisChild));

            scoreLabel.RunAction(seq);
        }
Exemplo n.º 12
0
        void ShowPointsWithFontLabelForValue(int pointValue, CCPoint positionToShowScore)
        {
            CCLabelTTF scoreLabel = new CCLabelTTF(string.Format("{0}", pointValue), "MarkerFelt", 22);
            AddChild(scoreLabel, Constants.DepthPointScore);
            scoreLabel.Color = new CCColor3B(255,255,255);
            scoreLabel.Position = positionToShowScore;

            CCMoveTo moveAction = new CCMoveTo(1.0f, new CCPoint ( scoreLabel.Position.X  , scoreLabel.Position.Y + 25 ));

            scoreLabel.RunAction(moveAction);

            CCSequence seq = new CCSequence(
                new CCFadeTo(1.5f, 20),
                new CCCallFuncN(RemoveThisLabel));

            scoreLabel.RunAction(seq);
        }