Ejemplo n.º 1
0
        public GroundParticle()
        {
            string [] particleData = new [] { "particle_ground.plist" };

            MainParticle = new CCParticleSystemQuad (particleData [0]);
            this.AddChild (MainParticle);

            LeftRotation = new CCRotateTo (0f, 0f);
            RightRotation = new CCRotateTo (0f, 180f);
        }
Ejemplo n.º 2
0
        public CCRotateToState (CCRotateTo action, CCNode target)
            : base (action, target)
        { 
            DistanceAngleX = action.DistanceAngleX;
            DistanceAngleY = action.DistanceAngleY;

            // Calculate X
            StartAngleX = Target.RotationX;
            if (StartAngleX > 0)
            {
                StartAngleX = StartAngleX % 360.0f;
            }
            else
            {
                StartAngleX = StartAngleX % -360.0f;
            }

            DiffAngleX = DistanceAngleX - StartAngleX;
            if (DiffAngleX > 180)
            {
                DiffAngleX -= 360;
            }
            if (DiffAngleX < -180)
            {
                DiffAngleX += 360;
            }

            //Calculate Y: It's duplicated from calculating X since the rotation wrap should be the same
            StartAngleY = Target.RotationY;

            if (StartAngleY > 0)
            {
                StartAngleY = StartAngleY % 360.0f;
            }
            else
            {
                StartAngleY = StartAngleY % -360.0f;
            }

            DiffAngleY = DistanceAngleY - StartAngleY;
            if (DiffAngleY > 180)
            {
                DiffAngleY -= 360;
            }

            if (DiffAngleY < -180)
            {
                DiffAngleY += 360;
            }
        }
Ejemplo n.º 3
0
        public CCRotateToState(CCRotateTo action, CCNode target)
            : base(action, target)
        {
            DistanceAngleX = action.DistanceAngleX;
            DistanceAngleY = action.DistanceAngleY;

            // Calculate X
            StartAngleX = Target.RotationX;
            if (StartAngleX > 0)
            {
                StartAngleX = StartAngleX % 360.0f;
            }
            else
            {
                StartAngleX = StartAngleX % -360.0f;
            }

            DiffAngleX = DistanceAngleX - StartAngleX;
            if (DiffAngleX > 180)
            {
                DiffAngleX -= 360;
            }
            if (DiffAngleX < -180)
            {
                DiffAngleX += 360;
            }

            //Calculate Y: It's duplicated from calculating X since the rotation wrap should be the same
            StartAngleY = Target.RotationY;

            if (StartAngleY > 0)
            {
                StartAngleY = StartAngleY % 360.0f;
            }
            else
            {
                StartAngleY = StartAngleY % -360.0f;
            }

            DiffAngleY = DistanceAngleY - StartAngleY;
            if (DiffAngleY > 180)
            {
                DiffAngleY -= 360;
            }

            if (DiffAngleY < -180)
            {
                DiffAngleY += 360;
            }
        }
Ejemplo n.º 4
0
		void HandleMoveCircle (CCTouch touch)
		{
			const float timeToTake = 1.5f; // in seconds
			CCFiniteTimeAction coreAction = null;

			// By default all actions will be added directly to the
			// root node - it has values for Position, Scale, and Rotation.
			CCNode nodeToAddTo = drawNodeRoot;

			switch (VariableOptions [currentVariableIndex]) {
			case "Position":
				coreAction = new CCMoveTo(timeToTake, touch.Location);
				break;
			case "Scale":
				var distance = CCPoint.Distance (touch.Location, drawNodeRoot.Position);
				var desiredScale = distance / DefaultCircleRadius;
				coreAction = new CCScaleTo (timeToTake, desiredScale);
				break;
			case "Rotation":
				float differenceY = touch.Location.Y - drawNodeRoot.PositionY;
				float differenceX = touch.Location.X - drawNodeRoot.PositionX;

				float angleInDegrees = -1 * CCMathHelper.ToDegrees (
					(float)Math.Atan2 (differenceY, differenceX));

				coreAction = new CCRotateTo (timeToTake, angleInDegrees);

				break;
			case "LineWidth":
				coreAction = new LineWidthAction (timeToTake, touch.Location.X / 40f);
				// The LineWidthAction is a special action designed to work only on
				// LineNode instances, so we have to set the nodeToAddTo to the lineNode:
				nodeToAddTo = lineNode;
				break;
			}

			CCAction easing = null;
			switch (EasingOptions [currentEasingIndex]) {
			case "CCEaseBack":
				if (currentInOutIndex == 0)
					easing = new CCEaseBackOut (coreAction);
				else if (currentInOutIndex == 1)
					easing = new CCEaseBackIn (coreAction);
				else
					easing = new CCEaseBackInOut (coreAction);

				break;
			case "CCEaseBounce":
				if (currentInOutIndex == 0)
					easing = new CCEaseBounceOut (coreAction);
				else if (currentInOutIndex == 1)
					easing = new CCEaseBounceIn (coreAction);
				else
					easing = new CCEaseBounceInOut (coreAction);

				break;
			case "CCEaseElastic":
				if (currentInOutIndex == 0)
					easing = new CCEaseElasticOut (coreAction);
				else if (currentInOutIndex == 1)
					easing = new CCEaseElasticIn (coreAction);
				else
					easing = new CCEaseElasticInOut (coreAction);

				break;
			case "CCEaseExponential":
				if (currentInOutIndex == 0)
					easing = new CCEaseExponentialOut (coreAction);
				else if (currentInOutIndex == 1)
					easing = new CCEaseExponentialIn (coreAction);
				else
					easing = new CCEaseExponentialInOut (coreAction);

				break;
			case "CCEaseSine":
				if (currentInOutIndex == 0)
					easing = new CCEaseSineOut (coreAction);
				else if (currentInOutIndex == 1)
					easing = new CCEaseSineIn (coreAction);
				else
					easing = new CCEaseSineInOut (coreAction);

				break;
			}

			nodeToAddTo.AddAction (easing ?? coreAction);
		}
Ejemplo n.º 5
0
 public ActionRotate()
 {
     actionTo = new CCRotateTo (2, 45);
     actionTo2 = new CCRotateTo (2, -45);
     actionTo0 = new CCRotateTo (2, 0);
     actionBy = new CCRotateBy (2, 360);
     actionByBack = (CCRotateBy)actionBy.Reverse();
 }
Ejemplo n.º 6
0
        public ActionSkewRotateScale()
        {
            box = new CCDrawNode();
            box.DrawRect(new CCRect (0.0f, 0.0f, 100.0f, 100.0f), new CCColor4B(255, 255, 0, 255));
            box.AnchorPoint = new CCPoint(0, 0);

            uL = new CCDrawNode();
            uL.DrawRect(new CCRect (0.0f, 0.0f, markrside, markrside), new CCColor4B(255, 0, 0, 255));
            uL.AnchorPoint = new CCPoint(0, 0);
            box.AddChild(uL);

            uR = new CCDrawNode();
            uR.DrawRect(new CCRect (0.0f, 0.0f, markrside, markrside), new CCColor4B(0, 0, 255, 255));
            uR.AnchorPoint = new CCPoint(0, 0);
            box.AddChild(uR);

            AddChild(box);

            actionTo = new CCSkewTo (2, 0.0f, 2.0f);
            rotateTo = new CCRotateTo (2, 61.0f);
            actionScaleTo = new CCScaleTo(2, -0.44f, 0.47f);

            actionScaleToBack = new CCScaleTo(2, 1.0f, 1.0f);
            rotateToBack = new CCRotateTo (2, 0);
            actionToBack = new CCSkewTo (2, 0, 0);
        }
Ejemplo n.º 7
0
        public override void OnEnter()
        {
            base.OnEnter(); 

            CenterSprites(3);

            var actionTo = new CCRotateTo(2, 180, 180);
            var actionToBack = new CCRotateTo(2, 0, 0);
            var actionBy = new CCRotateBy(2, 0.0f, 360);
            var actionByBack = actionBy.Reverse();

            var actionBy2 = new CCRotateBy(2, 360, 0.0f);
            var actionBy2Back = actionBy2.Reverse ();

            Tamara.RunActions(actionBy, actionByBack);
            Grossini.RunActions(actionTo, actionToBack);
            Kathia.RunActions(actionBy2, actionBy2Back);
        }
Ejemplo n.º 8
0
        public ActionRotateToRepeat()
        {
            var act1 = new CCRotateTo(1, 90);
            var act2 = new CCRotateTo(1, 0);
            var seq = new CCSequence(act1, act2);

            rep1 = new CCRepeatForever(seq);
            rep2 = new CCRepeat(seq, 10);
        }
Ejemplo n.º 9
0
 public void StartRotation()
 {
     float angle = (float)(360 / Math.PI * Math.Atan (VelocityX / VelocityY));
     angle += VelocityY < 0 ? 180 : 0;
     Random random = new Random ();
     float duration= (float)random.NextDouble()/2;
     CCRotateTo action = new CCRotateTo (duration, angle);
     AddAction (action);
 }
Ejemplo n.º 10
0
        public GameScene(CCWindow mainWindow, Container mainContainer, ControlType RunningControlType)
            : base(mainWindow)
        {
            CurrentControlType = RunningControlType;

            gameContainer = mainContainer;
            GameLayer = new MergedLayer (mainWindow, gameContainer);

            this.AddChild (GameLayer);

            screenSize = mainWindow.WindowSizeInPixels;

            //Touchlistener Initialisierung
            touchListener = new CCEventListenerTouchAllAtOnce ();

            switch (RunningControlType) {
            case ControlType.Slide:
                touchListener.OnTouchesMoved = Slide_HandleTouchesMoved;
                touchListener.OnTouchesBegan = Slide_HandleTouchesBegan;
                touchListener.OnTouchesEnded = Slide_HandleTouchesEnded;
                touchListener.OnTouchesCancelled = Slide_HandleTouchesCanceled;

                break;
            case ControlType.Button:
                JumpButton = new CCSprite ("menu_arrow");
                MoveLeftButton = new CCSprite ("menu_arrow");
                MoveRightButton = new CCSprite ("menu_arrow");

                JumpButton.Scale = screenSize.Width / 4 / JumpButton.TextureRectInPixels.Size.Width;
                MoveLeftButton.Scale = screenSize.Width / 6 / MoveLeftButton.TextureRectInPixels.Size.Width;
                MoveRightButton.Scale = screenSize.Width / 6 / MoveRightButton.TextureRectInPixels.Size.Width;

                JumpButton.Position = new CCPoint (screenSize.Width - JumpButton.ScaledContentSize.Width / 2, JumpButton.ScaledContentSize.Height / 2);
                MoveLeftButton.Position = new CCPoint (MoveLeftButton.ScaledContentSize.Width / 2, MoveLeftButton.ScaledContentSize.Height / 2);
                MoveRightButton.Position = new CCPoint (MoveLeftButton.PositionX + 20f + MoveRightButton.ScaledContentSize.Width, MoveLeftButton.ScaledContentSize.Height / 2);

                CCRotateTo LeftRotate = new CCRotateTo (0, 270f);
                MoveLeftButton.RunAction (LeftRotate);

                CCRotateTo RightRotate = new CCRotateTo (0, 90f);
                MoveRightButton.RunAction (RightRotate);

                this.AddChild (JumpButton);
                this.AddChild (MoveLeftButton);
                this.AddChild (MoveRightButton);

                touchListener.OnTouchesMoved = Button_HandleTouchesMoved;
                touchListener.OnTouchesBegan = Button_HandleTouchesBegan;
                touchListener.OnTouchesEnded = Button_HandleTouchesEnded;
                touchListener.OnTouchesCancelled = Button_HandleTouchesCanceled;

                break;
            }

            AddEventListener (touchListener, this);

            //FPS Label
            FPSLabel = new CCLabel ("Score: 0", "arial", 22);
            FPSLabel.Position = new CCPoint (100, 100);
            FPSLabel.Color = new CCColor3B (255, 255, 0);
            AddChild (FPSLabel);

            //Map Label
            MapNameLabel = new CCLabel ("Map Name : " + GameLayer.mapName, "arial", 22) {
                Color = new CCColor3B (255, 255, 255)
            };
            MapNameLabel.Position = new CCPoint (MapNameLabel.ContentSize.Width / 2, screenSize.Height - 10 - MapNameLabel.ContentSize.Height);
            MapCreatorLabel = new CCLabel ("Map Creator : " + GameLayer.mapCreator, "arial", 22) {
                Color = new CCColor3B (255, 255, 255)
            };
            MapCreatorLabel.Position = new CCPoint (MapCreatorLabel.ContentSize.Width / 2, MapNameLabel.Position.Y - 10 - MapCreatorLabel.ContentSize.Height);
            MapVersionLabel = new CCLabel ("Map Version : " + GameLayer.mapVersion, "arial", 22) {
                Color = new CCColor3B (255, 255, 255)
            };
            MapVersionLabel.Position = new CCPoint (MapVersionLabel.ContentSize.Width / 2, MapCreatorLabel.Position.Y - 10 - MapVersionLabel.ContentSize.Height);

            this.AddChild (MapNameLabel);
            this.AddChild (MapCreatorLabel);
            this.AddChild (MapVersionLabel);

            //Interface
            ManaSprite = new CCSprite[2];
            LifeSprite = new CCSprite[2];

            ManaSprite [0] = new CCSprite ("bottleinside"){ IsAntialiased = false };
            ManaSprite [1] = new CCSprite ("bottleoutside"){ IsAntialiased = false };
            LifeSprite [0] = new CCSprite ("lifefull"){ IsAntialiased = false };
            LifeSprite [1] = new CCSprite ("lifeempty"){ IsAntialiased = false };

            ManaSprite [0].Scale = 12f;
            ManaSprite [1].Scale = 12f;
            LifeSprite [0].Scale = 12f;
            LifeSprite [1].Scale = 12f;

            ManaSprite [1].Position = new CCPoint (screenSize.Width - ManaSprite [1].ScaledContentSize.Width, screenSize.Height - ManaSprite [1].ScaledContentSize.Height);
            LifeSprite [1].Position = new CCPoint (screenSize.Width - LifeSprite [1].ScaledContentSize.Width, ManaSprite [1].Position.Y - LifeSprite [1].ScaledContentSize.Height);

            this.AddChild (ManaSprite [1]);
            this.AddChild (ManaSprite [0]);
            this.AddChild (LifeSprite [1]);
            this.AddChild (LifeSprite [0]);

            this.InterfaceUpdate (null, new StatisticChangeEventArgHandler (Statistic.Life));
            this.InterfaceUpdate (null, new StatisticChangeEventArgHandler (Statistic.Mana));

            gameContainer.mainCharacter.StatChanged += InterfaceUpdate;

            gameContainer.mainCharacter.CurrentLife = 23;
            gameContainer.mainCharacter.CurrentMana = 4;

            Schedule (GameLoop);
        }
Ejemplo n.º 11
0
		private void HandleMoveCircle(CCTouch touch)
		{
			const float timeToTake = 1.5f; // in seconds
			CCFiniteTimeAction coreAction = null;

			CCNode nodeToAddTo = drawNodeRoot;

			switch (VariableOptions [currentVariableIndex])
			{
			case "Position":
				coreAction = new CCMoveTo(timeToTake, touch.Location);

					break;
			case "Scale":
					var distance = CCPoint.Distance (touch.Location, drawNodeRoot.Position);
					var desiredScale = distance / DefaultCircleRadius;
					coreAction = new CCScaleTo(timeToTake, desiredScale);

					break;
			case "Rotation":
					float differenceY = touch.Location.Y - drawNodeRoot.PositionY;
					float differenceX = touch.Location.X - drawNodeRoot.PositionX;

					float angleInDegrees = -1 * CCMathHelper.ToDegrees(
						(float)System.Math.Atan2(differenceY, differenceX));

					coreAction = new CCRotateTo (timeToTake, angleInDegrees);

					break;
				case "LineWidth":
					coreAction = new LineWidthAction (timeToTake, touch.Location.X / 40.0f);
					nodeToAddTo = lineNode;
					break;
			}

			CCAction easing = null;
			switch (EasingOptions [currentEasingIndex])
			{
				case "<None>":
					// no easing, do nothing, it will be handled below
					break;
				case "CCEaseBack":
					if (currentInOutIndex == 0)
						easing = new CCEaseBackOut (coreAction);
					else if (currentInOutIndex == 1)
						easing = new CCEaseBackIn (coreAction);
					else
						easing = new CCEaseBackInOut (coreAction);

					break;
				case "CCEaseBounce":
					if (currentInOutIndex == 0)
						easing = new CCEaseBounceOut (coreAction);
					else if (currentInOutIndex == 1)
						easing = new CCEaseBounceIn (coreAction);
					else
						easing = new CCEaseBounceInOut (coreAction);

					break;
				case "CCEaseElastic":
					if (currentInOutIndex == 0)
						easing = new CCEaseElasticOut (coreAction);
					else if (currentInOutIndex == 1)
						easing = new CCEaseElasticIn (coreAction);
					else
						easing = new CCEaseElasticInOut (coreAction);

					break;
				case "CCEaseExponential":
					if (currentInOutIndex == 0)
						easing = new CCEaseExponentialOut (coreAction);
					else if (currentInOutIndex == 1)
						easing = new CCEaseExponentialIn (coreAction);
					else
						easing = new CCEaseExponentialInOut (coreAction);

					break;
				case "CCEaseSine":

					if (currentInOutIndex == 0)
						easing = new CCEaseSineOut (coreAction);
					else if (currentInOutIndex == 1)
						easing = new CCEaseSineIn (coreAction);
					else
						easing = new CCEaseSineInOut (coreAction);

					break;
			}

			if (easing != null)
			{
				nodeToAddTo.AddAction (easing);
			}
			else
			{
				nodeToAddTo.AddAction (coreAction);
			}

		}