Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        /**********************************************************************
         *********************************************************************/
        //Receiver sends ACK
        public static void SendACKFor(int seqnum)
        {
            if (!stopEverything)
            {
                //define object
                float yPos = 15 + (65 * (28 - seqnum)); //where the box !starts!
                OldPipelineProtocolsACK pp;

                //smaller rectangle at --
                switch (seqnum)
                {
                case -1:
                    pp   = new OldPipelineProtocolsACK(seqnum, 5, 1);
                    yPos = yPos + 12;     //since it's smaller, it has to be a little further up, in order to look pretty
                    break;

                default:
                    pp = new OldPipelineProtocolsACK(seqnum, 0);
                    break;
                }
                pp.Position = new CCPoint(280, yPos);
                layer.AddChild(pp);

                //define action
                float timeToTake        = 5f;
                var   distance          = new CCPoint(80, yPos);              //82 to 278 = 278-82 = 196
                var   sendPackageAction = new CCMoveTo(timeToTake, distance); //this action moves the object 196 in x-direction within 5 seconds
                var   removeAction      = new CCRemoveSelf();                 //this action removes the object*/

                //define sequence of actions and apply to object
                var cc_seq1 = new CCSequence(sendPackageAction, removeAction);
                pp.RunAction(cc_seq1);
            }
        }
Exemplo n.º 3
0
        private void CreateLogo()
        {
            // create logo graphic
            var logo = new CCSprite("Logo.png");

            logo.BlendFunc     = CCBlendFunc.NonPremultiplied;
            logo.AnchorPoint   = new CCPoint(0, 0);
            logo.PositionX     = (base.GameView.DesignResolution.Width - logo.ContentSize.Width) / 2;
            logo.PositionY     = GameConfig.LOGO_POSITION_Y;
            logo.IsAntialiased = false;
            foregroundLayer.AddChild(logo);

            // start position
            var startPositionX = -500.0f;
            var startPositionY = GameConfig.LOGO_POSITION_Y;

            logo.PositionX = startPositionX;
            logo.PositionY = startPositionY;

            // end position
            var endPositionX = (base.GameView.DesignResolution.Width - logo.ContentSize.Width) / 2;
            var endPositionY = startPositionY;

            // create and run ease move action
            var point      = new CCPoint(endPositionX, endPositionY);
            var coreAction = new CCMoveTo(4.0f, point);
            var easeAction = new CCEaseElasticOut(coreAction);

            logo.RunAction(easeAction);
        }
Exemplo n.º 4
0
        private void CreateButtons()
        {
            var i = 0;

            foreach (var buttonText in GameConfig.BUTTONS_DICTIONARY.Keys)
            {
                // create button and set action
                var button = new Button(buttonText);
                button.Action = GameConfig.BUTTONS_DICTIONARY[buttonText];

                // add button
                foregroundLayer.AddChild(button);
                buttons.Add(button);

                // start position
                var startPositionX = (base.GameView.DesignResolution.Width - button.ContentSize.Width) / 2;
                var startPositionY = GameConfig.PLAY_BUTTON_POSITION_Y - i * 170 - GameConfig.PLAY_BUTTON_POSITION_Y;
                button.PositionX = startPositionX;
                button.PositionY = startPositionY;

                // end position
                var endPositionX = (base.GameView.DesignResolution.Width - button.ContentSize.Width) / 2;
                var endPositionY = GameConfig.PLAY_BUTTON_POSITION_Y - i * 170;

                // create and run ease move action
                var point      = new CCPoint(endPositionX, endPositionY);
                var coreAction = new CCMoveTo(4.0f, point);
                var easeAction = new CCEaseBackOut(coreAction);
                button.RunAction(easeAction);

                // increment counter
                i += 1;
            }
        }
Exemplo n.º 5
0
        void MoveClouds()
        {
            if ((windSpeedChanged == true) &&
                (windSpeed > 0))
            {
                CCRepeatForever cloudsAnimation;
                float           targetPositionX      = (windBlowingRight == true ? layerWidth + 350 : -350f);
                CCSequence      cloudsMovingSequence = new CCSequence(new CCMoveBy(0, new CCPoint(0, 0)));
                CCMoveTo        moveAcrossTo         = new CCMoveTo(windSpeed * 3f, new CCPoint(targetPositionX, cloudsParallax.PositionY));
                CCEaseSineIn    easeInAcrossTo       = new CCEaseSineIn(moveAcrossTo);

                cloudsMovingSequence = new CCSequence(moveAcrossTo,
                                                      new CCCallFunc(() => cloudsParallax.PositionX = (windBlowingRight == true ? -350f :
                                                                                                       layerWidth + 350)));
                cloudsAnimation = new CCRepeatForever(cloudsMovingSequence);

                cloudsParallax.StopAllActions();
                cloudsParallax.RunActions(easeInAcrossTo, cloudsAnimation);
            }
            else if (windSpeed < float.Epsilon)
            {
                float         targetPositionX = (windBlowingRight == true ? previousWindSpeed * 7 : previousWindSpeed * -7);
                CCEaseSineOut easeOutBy       = new CCEaseSineOut(new CCMoveBy(previousWindSpeed * 1.2f, new CCPoint(targetPositionX, 0)));

                cloudsParallax.StopAllActions();
                cloudsParallax.RunAction(easeOutBy);
            }
        }
Exemplo n.º 6
0
        /** creates the action */
        public static CCMoveTo actionWithDuration(float duration, CCPoint position)
        {
            CCMoveTo moveTo = new CCMoveTo();
            moveTo.initWithDuration(duration, position);

            return moveTo;
        }
        public TMXUncompressedTest()
        {
            CCLayerColor color = CCLayerColor.layerWithColor(new ccColor4B(64, 64, 64, 255));

            addChild(color, -1);

            CCTMXTiledMap map = CCTMXTiledMap.tiledMapWithTMXFile("TileMaps/iso-test2-uncompressed");

            addChild(map, 0, TileMapTestScene.kTagTileMap);

            CCSize s = map.contentSize;
            ////----UXLOG("ContentSize: %f, %f", s.width,s.height);

            // move map to the center of the screen
            CCSize ms = map.MapSize;
            CCSize ts = map.TileSize;

            map.runAction(CCMoveTo.actionWithDuration(1.0f, new CCPoint(-ms.width * ts.width / 2, -ms.height * ts.height / 2)));

            // testing release map
            CCTMXLayer layer;

            foreach (var pObject in map.children)
            {
                layer = (CCTMXLayer)pObject;

                if (layer == null)
                {
                    break;
                }

                layer.releaseMap();
            }
        }
Exemplo n.º 8
0
        /**********************************************************************
         *********************************************************************/
        //this method imitates the sender of a packet. It is called by the method invoke
        public static void SendPackageAt(int seqnum)
        {
            if (!stopEverything)
            {
                if (seqnum == nextSeqnum)
                {
                    DrawFillLeft(seqnum);
                }

                //pending if not already acknowledged . Add to list only once
                if (!arrivedAck.Any() && !pendingAck.Contains(seqnum) ||
                    arrivedAck.Any() && !arrivedAck.Contains(seqnum) && !pendingAck.Contains(seqnum))
                {
                    pendingAck.Add(seqnum);
                }

                //define object
                float yPos = 15 + (65 * (28 - seqnum)); //calculate where the box !starts! in the coordinate system
                var   pp   = new OldPipelineProtocolsPack(seqnum, 0);
                pp.Position = new CCPoint(80, yPos);
                layer.AddChild(pp);

                //define actions
                float timeToTake        = 5f;
                var   distance          = new CCPoint(280, yPos);             //82 to 278 = 278-82 = 196
                var   sendPackageAction = new CCMoveTo(timeToTake, distance); //this action moves the object 196 in x-direction within 5 seconds
                var   removeAction      = new CCRemoveSelf();                 //this action removes the object

                //define sequence of actions and apply to object
                var cc_seq1 = new CCSequence(sendPackageAction, removeAction);
                pp.RunAction(cc_seq1);
            }
        }
Exemplo n.º 9
0
        void OnTouchesEnded(List <CCTouch> touches, CCEvent touchEvent)
        {
            monkey.StopAllActions();

            var location = touches [0].LocationOnScreen;

            location = WorldToScreenspace(location);

            if (location.Y >= allowableMovementRect.Size.Height)
            {
                location.Y = allowableMovementRect.Size.Height;
            }

            float ds = CCPoint.Distance(monkey.Position, location);

            var dt = ds / monkeySpeed;

            var moveMonkey = new CCMoveTo(dt, location);

            //BUG: calling walkRepeat separately as it doesn't run when called in RunActions or CCSpawn
            monkey.RunAction(walkRepeat);
            monkey.RunActions(moveMonkey, walkAnimStop);

            // move the clouds relative to the monkey's movement
            MoveClouds(location.Y - monkey.Position.Y);
        }
Exemplo n.º 10
0
        //Déplacement au sol
        public void GoDown()
        {
            UpdatePointDown();
            var coreAction = new CCMoveTo(0.1f, pointDown);

            AddAction(coreAction);
        }
Exemplo n.º 11
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));
        }
Exemplo n.º 12
0
        public override bool init()
        {
            if (base.init())
            {
                CCSize s = CCDirector.sharedDirector().getWinSize();

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

                CCLayerColor sprite_a = CCLayerColor.layerWithColorWidthHeight(new ccColor4B(255, 0, 0, 255), 700, 700);
                sprite_a.anchorPoint           = new CCPoint(0.5f, 0.5f);
                sprite_a.isRelativeAnchorPoint = true;
                sprite_a.position = new CCPoint(0.0f, s.height / 2);
                addChild(sprite_a);

                sprite_a.runAction(CCRepeatForever.actionWithAction((CCActionInterval)CCSequence.actions(
                                                                        CCMoveTo.actionWithDuration(1.0f, new CCPoint(1024.0f, 384.0f)),
                                                                        CCMoveTo.actionWithDuration(1.0f, new CCPoint(0.0f, 384.0f)))));

                CCLayerColor sprite_b = CCLayerColor.layerWithColorWidthHeight(new ccColor4B(0, 0, 255, 255), 400, 400);
                sprite_b.anchorPoint           = new CCPoint(0.5f, 0.5f);
                sprite_b.isRelativeAnchorPoint = true;
                sprite_b.position = new CCPoint(s.width / 2, s.height / 2);
                addChild(sprite_b);

                CCMenuItemLabel label = CCMenuItemLabel.itemWithLabel(CCLabelTTF.labelWithString("Flip Me", "Helvetica", 24), this, callBack);
                CCMenu          menu  = CCMenu.menuWithItems(label);
                menu.position = new CCPoint(s.width - 200.0f, 50.0f);
                addChild(menu);

                return(true);
            }

            return(false);
        }
Exemplo n.º 13
0
        private void RunOutroAnimations()
        {
            var slideOutHeader = new CCMoveTo(1, new CCPoint(0, 200));
            var sequence       = new CCSequence(slideOutHeader, new CCDelayTime(0.2f), new CCCallFunc(() => CCDirector.SharedDirector.ReplaceScene(new MainScene())));

            _gameHeader.RunAction(sequence);
        }
Exemplo n.º 14
0
        public void SetPosition(CCPoint point)
        {
            var coreAction = new CCMoveTo(0, point);

            AddAction(coreAction);
            UpdatePointDown();
        }
Exemplo n.º 15
0
        public void ChangeSquaresPosition(float timeForChanging, PositionInGame firstPosition, PositionInGame secondPosition, Action callback = null)
        {
            //var firstPosition = (PositionInGame)_random.Next(firstPositionInGame, lastPositionInGame);
            //var secondPosition = (PositionInGame)_random.Next(firstPositionInGame, lastPositionInGame);
            //while (firstPosition == secondPosition)
            //    secondPosition = (PositionInGame)_random.Next(firstPositionInGame, lastPositionInGame);


            var firstSquarePosition  = _cordinatesGenerator.PositionAndSquare[firstPosition];
            var secondSquarePosition = _cordinatesGenerator.PositionAndSquare[secondPosition];

            var firstSquare  = firstSquarePosition;
            var secondSquare = secondSquarePosition;

            _cordinatesGenerator.PositionAndSquare[firstPosition]  = secondSquare;
            _cordinatesGenerator.PositionAndSquare[secondPosition] = firstSquare;


            var moveToFirstPosition  = new CCMoveTo(timeForChanging, new CCPoint(firstSquare.Position.X, firstSquare.Position.Y));
            var moveToSecondPosition = new CCMoveTo(timeForChanging, new CCPoint(secondSquare.Position.X, secondSquare.Position.Y));

            secondSquare.RunAction(moveToFirstPosition);

            if (callback != null)
            {
                var        moveCompletedAction = new CCCallFunc(callback);
                CCSequence mySequence          = new CCSequence(moveToSecondPosition, moveCompletedAction);

                firstSquare.RunAction(mySequence);
            }
            else
            {
                firstSquare.RunAction(moveToSecondPosition);
            }
        }
Exemplo n.º 16
0
        bool MoveGem(GemSprite gem)
        {
            if (gem == null)
            {
                return(false);
            }
            var col = gem.Col;
            var row = gem.Row;

            // Check if gem place corresponds its cell place
            // if not - it should move
            if (gem.Cell.Col != gem.Col || gem.Cell.Row != gem.Row)
            {
                var newPlace = places[gem.Cell.Col, gem.Cell.Row];
                var target   = new CCPoint(newPlace.PositionX, newPlace.PositionY);

                gem.Col = gem.Cell.Col;
                gem.Row = gem.Cell.Row;

                var moveAction = new CCMoveTo(CellAnimationDuration, target);
                var ease       = new CCEaseIn(moveAction, 4);

                gem.AddAction(ease);
                return(true);
            }
            return(false);
        }
Exemplo n.º 17
0
        public void Hide()
        {
            //指定移动到最左边并超出屏幕
            CCMoveTo move = CCMoveTo.actionWithDuration(0.5f, new CCPoint(-CCDirector.sharedDirector().getWinSize().width, 0));

            //执行一个队列行为,当移动完成后就会调用HideAniCompled
            this.runAction(CCSequence.actionOneTwo(move, CCCallFunc.actionWithTarget(this, HideAniCompled)));
        }
Exemplo n.º 18
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);
        }
Exemplo n.º 19
0
        /** creates the action */
        public static CCMoveTo actionWithDuration(float duration, CCPoint position)
        {
            CCMoveTo moveTo = new CCMoveTo();

            moveTo.initWithDuration(duration, position);

            return(moveTo);
        }
Exemplo n.º 20
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            var layer1 = new CCLayerColor(new CCColor4B(0xFF, 0xFF, 0x00, 0x80));

            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));
            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);


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

            m_pInnerLayer.RepeatForever(scaleTo2, scaleTo3);


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

            m_pInnerLayer.RunAction(seq);

            CCSize size = Layer.VisibleBoundsWorldspace.Size;

            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.º 21
0
        void MoveShipTo(CCPoint location)
        {
            float ds = CCPoint.Distance(ship.Position, location);
            var   dt = ds / SHIP_SPEED;

            var moveShip = new CCMoveTo(dt, location);
            var easeShip = new CCEaseSineInOut(moveShip);

            ship.RunAction(easeShip);
        }
Exemplo n.º 22
0
        void Fire()
        {
            var shot = new CCDrawNode();

            shot.DrawCircle(new CCPoint(0, 0), SHOT_RADIUS, CCColor4B.Red);
            shots.AddChild(shot);
            shot.Position = new CCPoint(ship.Position.X + 60.0f, ship.Position.Y - 2.5f);

            var moveShot = new CCMoveTo(1.0f, new CCPoint(VisibleBoundsWorldspace.MaxX, shot.Position.Y));

            shot.RunActions(moveShot, removeNodeAction);
        }
Exemplo n.º 23
0
        private PlayerBullet AddPlayerBullet()
        {
            PlayerBullet bullet = new PlayerBullet();

            bullet.Position = new CCPoint(player.Position.X, player.Position.Y + player.ContentSize.Height / 2);
            AddChild(bullet, PLAYER_BULLET_INDEX);

            var moveBullet = new CCMoveTo(5.0f, new CCPoint(bullet.Position.X, VisibleBoundsWorldspace.MaxY));

            bullet.RunActions(moveBullet, moveOutOfView);
            return(bullet);
        }
Exemplo n.º 24
0
        public void Show()
        {
            //将其显示出来
            this.visible = true;
            //把位置设置到最右边出屏幕外
            this.position = new CCPoint(CCDirector.sharedDirector().getWinSize().width, 0);
            //指定移动到0,0点
            CCMoveTo move = CCMoveTo.actionWithDuration(0.5f, new CCPoint(0, 0));

            //运行这个Action
            this.runAction(move);
        }
Exemplo n.º 25
0
        void AddEnemy()
        {
            var enemy = new CCDrawNode();

            enemy.DrawCircle(new CCPoint(0, 0), ENEMY_RADIUS, CCColor4B.Blue);
            enemy.Position = GetRandomPointY(ENEMY_RADIUS);
            enemies.AddChild(enemy);

            var moveEnemy = new CCMoveTo(3.0f, new CCPoint(0, enemy.Position.Y));

            enemy.RunActions(moveEnemy, removeNodeAction);
        }
Exemplo n.º 26
0
        async public void MoveAsync()
        {
            // move up cube row one time and remove it from parent afterwards
            var duration = GameConfig.ACTION_DURATION_WITH_DELTA;
            var distance = GameConfig.MOVE_DISTANCE_Y;
            var point    = new CCPoint(PositionX, PositionY + distance);

            // create action that moves cube row to final position
            var move = new CCMoveTo(duration, point);

            // run actions
            await RunActionsAsync(move, removeFirstAndSpawnNewCubeRow);
        }
Exemplo n.º 27
0
        void MoveBoat(bool ignoreWindspeedChange)
        {
            if ((windSpeedChanged == true) ||
                (ignoreWindspeedChange == true))
            {
                CCRepeatForever boatMovingAnimation;
                CCSequence      boatMovingSequence;

                if (windSpeed > 0)
                {
                    float      targetPositionX = (windBlowingRight == true ? layerWidth + boatSprite.ContentSize.Width : -boatSprite.ContentSize.Width);
                    CCMoveTo   moveAcrossTo    = new CCMoveTo(windSpeed * 1.4f, new CCPoint(targetPositionX, boatSprite.PositionY));
                    CCCallFunc resetPositionX  = new CCCallFunc(() => boatSprite.PositionX = (windBlowingRight == true ? -boatSprite.ContentSize.Width :
                                                                                              layerWidth + boatSprite.ContentSize.Width));
                    CCEaseSineIn easeInAcrossTo = new CCEaseSineIn(moveAcrossTo);

                    previousWindSpeed   = windSpeed * 1.4f;
                    boatMovingSequence  = new CCSequence(resetPositionX, moveAcrossTo);
                    boatMovingAnimation = new CCRepeatForever(boatMovingSequence);

                    boatSprite.StopAllActions();
                    boatSprite.RunActions(easeInAcrossTo, boatMovingAnimation);
                }
                else if (previousWindSpeed > 0)
                {
                    float         targetPositionX = (windBlowingRight == true ? previousWindSpeed * 7 : previousWindSpeed * -7);
                    CCEaseSineOut easeOutBy       = new CCEaseSineOut(new CCMoveBy(previousWindSpeed * 1.2f, new CCPoint(targetPositionX, 0)));
                    CCEaseSineOut easeOutSlowerBy = new CCEaseSineOut(new CCMoveBy(previousWindSpeed * 1.4f, new CCPoint(targetPositionX, 0)));
                    CCEaseSineIn  easeInTo        = new CCEaseSineIn(new CCMoveTo(0.5f, new CCPoint(boatSprite.PositionX, oceanSprite.PositionY +
                                                                                                    boatSprite.ContentSize.Height / 2 - 3)));
                    CCCallFunc resetBoatPositionX = new CCCallFunc(() =>
                    {
                        if ((windBlowingRight == true) &&
                            (boatSprite.PositionX >= layerWidth + boatSprite.ContentSize.Width))
                        {
                            boatSprite.PositionX = -boatSprite.ContentSize.Width;
                        }
                        else if ((windBlowingRight == false) &&
                                 (boatSprite.PositionX <= -boatSprite.ContentSize.Width))
                        {
                            boatSprite.PositionX = layerWidth + boatSprite.ContentSize.Width;
                        }
                    });

                    boatMovingSequence = new CCSequence(easeOutBy, resetBoatPositionX, easeOutSlowerBy, easeInTo, boatAnimation);

                    boatSprite.StopAllActions();
                    boatSprite.RunAction(boatMovingSequence);
                }
            }
        }
Exemplo n.º 28
0
        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);
        }
Exemplo n.º 29
0
        private EnemyBullet AddEnemyBullet(CCSprite sender)
        {
            EnemyBullet bullet = new EnemyBullet();

            bullet.Position = new CCPoint(sender.Position.X, sender.Position.Y - sender.ContentSize.Height / 2);
            AddChild(bullet, ENEMY_BULLET_INDEX);

            CCPoint target   = CCPoint.IntersectPoint(bullet.Position, player.Position, CCPoint.Zero, new CCPoint(VisibleBoundsWorldspace.MaxX, 0));
            float   distance = CCPoint.Distance(bullet.Position, target);

            var moveBullet = new CCMoveTo(distance / ENEMY_BULLET_SPEED, target);

            bullet.RunActions(moveBullet, moveOutOfView);
            return(bullet);
        }
        public void OnTouchesEnded(List <CCTouch> touches, CCEvent touchEvent)
        {
            monkey.StopAllActions();
            var location = touches[0].LocationOnScreen;

            location = WorldToScreenspace(location);
            float ds = CCPoint.Distance(monkey.Position, location);

            var dt = ds / Money_Speed;

            var MoveMonkey = new CCMoveTo(dt, location);

            monkey.RunAction(walkRepeat);
            monkey.RunActions(MoveMonkey, walkAnimStop);
            CCSimpleAudioEngine.SharedEngine.PlayEffect("Sounds/tap");
        }
Exemplo n.º 31
0
        void OnTouchesEnded(List <CCTouch> touches, CCEvent touchEvent)
        {
            base.TouchesEnded(touches, touchEvent);

            var location = touches [0].Location;

            float ds = CCPoint.Distance(monkey.Position, location);

            float dt = ds / MONKEY_SPEED;

            var moveMonkey = new CCMoveTo(dt, location);

            monkey.RunAction(moveMonkey);

            CCSimpleAudioEngine.SharedEngine.PlayEffect("Sounds/tap.mp3");
        }
Exemplo n.º 32
0
        public override CCObject copyWithZone(CCZone zone)
        {
            CCZone tmpZone = zone;
            CCMoveTo ret = null;

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

            base.copyWithZone(tmpZone);
            ret.initWithDuration(m_fDuration, m_endPosition);

            return ret;
        }
Exemplo n.º 33
0
 protected CCMoveTo(CCMoveTo moveTo)
     : base(moveTo)
 {
     InitWithDuration(moveTo.m_fDuration, moveTo.m_endPosition);
 }
Exemplo n.º 34
0
 public CCMoveToState (CCMoveTo action, CCNode target)
     : base (action, target)
 { 
     StartPosition = target.Position;
     PositionDelta = action.PositionEnd - target.Position;
 }