public override void OnEnter()
        {
            base.OnEnter();

            CCSize winSize = VisibleBoundsWorldspace.Size;
            float x = winSize.Center.X;
            float y = winSize.Center.Y;

            //var widgetSize = _widget->getContentSize();

            var moveTo = new CCMoveBy(1.0f, new CCPoint(30, 0));
            var moveBack = moveTo.Reverse();
            var rotateBy = new CCRotateBy(1.0f, 180);
            var scaleBy = new CCScaleTo(1.0f, -2.0f);
            var action = new CCSequence(moveTo, moveBack, rotateBy, scaleBy);


            var normalSprite1 = new CCSprite("Images/animationbuttonnormal.png");
            normalSprite1.Position = winSize.Center;
            normalSprite1.PositionX -= 100;
            normalSprite1.PositionY += 100;
            normalSprite1.FlipY = true;


            AddChild(normalSprite1);
            normalSprite1.RunAction(action);

            var normalSprite2 = new CCScale9Sprite("Images/animationbuttonnormal.png");
            normalSprite2.Position = winSize.Center;
            normalSprite2.PositionX -= 80;
            normalSprite2.PositionY += 100;
            normalSprite2.IsScale9Enabled = false;
            normalSprite2.Opacity = 100;
            AddChild(normalSprite2);
            normalSprite2.Color = CCColor3B.Green;
            normalSprite2.RunAction(action);

            
            var sp1 = new CCScale9Sprite("Images/animationbuttonnormal.png");
            sp1.Position = winSize.Center;
            sp1.PositionX -= 100;
            sp1.PositionY -= 50;
            sp1.Scale = 1.2f;
            sp1.ContentSize = new CCSize(100, 100);
            sp1.Color = CCColor3B.Green;
            AddChild(sp1);
            sp1.RunAction(action);

            var sp2 = new CCScale9Sprite("Images/animationbuttonnormal.png");
            sp2.Position = winSize.Center;
            sp2.PositionX += 100;
            sp2.PositionY -= 50;
            sp2.PreferredSize = sp1.ContentSize * 1.2f;
            sp2.ContentSize = new CCSize(100, 100);
            sp2.Color = CCColor3B.Green;
            AddChild(sp2);
            sp2.RunAction(action);

        }
예제 #2
0
        protected override void AddedToScene()
        {
            base.AddedToScene();

            var bounds = VisibleBoundsWorldspace;
            var action = new CCScaleTo(1.0f, 1.0f);

            titleLabel.Position = new CCPoint(bounds.Center.X, 50);

            menu.Position = new CCPoint(bounds.Center.X, bounds.MaxY - 100);
            onOffSwitch.Scale = 0.1f;
            onOffSwitch.RunActions(action);

            frequencyLabel.Position = new CCPoint(bounds.Center.X, bounds.Center.Y + 120);
            frequencyKnob.Scale = 0.0f;
            frequencyKnob.Position = bounds.Center;
            frequencyKnob.AnchorPoint = new CCPoint(0.5f, 0.5f);
            frequencyKnob.RunActions(action);

            var touchListener = new CCEventListenerTouchAllAtOnce();
            touchListener.OnTouchesBegan = OnTouchesBegan;
            touchListener.OnTouchesMoved = OnTouchesMoved;
            touchListener.OnTouchesEnded = OnTouchesEnded;

            AddEventListener(touchListener, this);

            UpdateFrequency(frequency);

            var appDelegate = Application.ApplicationDelegate as AppDelegate;
            if (appDelegate != null && appDelegate.BackButtonWasPressed != null)
            {
                Schedule((dt) =>
                {
                    if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                    {
                        appDelegate.BackButtonWasPressed();
                    }
                });
            }
        }
예제 #3
0
        protected override void Step(float dt)
        {
            base.Step(dt);

            if (gameSuspended)
                return;

            var batchnode = GetChildByTag((int)Tags.SpriteManager) as CCSpriteBatchNode;
            var bird = batchnode.GetChildByTag((int)Tags.Bird) as CCSprite;
            var particles = GetChildByTag((int)Tags.Particles) as CCParticleSystem;

            bird_pos.X += bird_vel.X * dt;

            if (bird_vel.X < -30.0f && birdLookingRight)
            {
                birdLookingRight = false;
                bird.ScaleX = -1.0f;
            }
            else if (bird_vel.X > 30.0f && !birdLookingRight)
            {
                birdLookingRight = true;
                bird.ScaleX = 1.0f;
            }

            var bird_size = bird.ContentSize;
            float max_x = 320 - bird_size.Width / 2;
            float min_x = 0 + bird_size.Width / 2;

            if (bird_pos.X > max_x) bird_pos.X = max_x;
            if (bird_pos.X < min_x) bird_pos.X = min_x;

            bird_vel.Y += bird_acc.Y * dt;
            bird_pos.Y += bird_vel.Y * dt;

            var bonus = batchnode.GetChildByTag((int)Tags.BomusStart + currentBonusType);
            if (bonus.Visible)
            {
                var bonus_pos = bonus.Position;
                float range = 20.0f;
                if (bird_pos.X > bonus_pos.X - range &&
                   bird_pos.X < bonus_pos.Y + range &&
                   bird_pos.Y > bonus_pos.Y - range &&
                   bird_pos.Y < bonus_pos.Y + range)
                {
                    switch (currentBonusType)
                    {
                        case (int)Bonus.Bonus5: score += 5000; break;
                        case (int)Bonus.Bonus10: score += 10000; break;
                        case (int)Bonus.Bonus50: score += 50000; break;
                        case (int)Bonus.Bonus100: score += 100000; break;
                    }
                    var scorelabel = GetChildByTag((int)Tags.ScoreLabel) as CCLabelBMFont;
                    scorelabel.Text = score.ToString();

                    var a1 = new CCScaleTo(.2f, 1.5f, .08f);
                    var a2 = new CCScaleTo(.2f, 1f, 1f);
                    var a3 = new CCSequence(a1, a2, a1, a2, a1, a2);
                    scorelabel.RunAction(a3);
                    ResetBonus();
                }
            }

            int t;

            if (bird_vel.Y < 0)
            {

                t = (int)Tags.PlatformsStart;
                for (t = (int)Tags.PlatformsStart; t < (int)Tags.PlatformsStart + numPlatforms; t++)
                {
                    var platform = batchnode.GetChildByTag(t) as CCSprite;

                    var platform_size = platform.ContentSize;
                    var platform_pos = platform.Position;

                    max_x = platform_pos.X - platform_size.Width / 2 - 10;
                    min_x = platform_pos.X + platform_size.Width / 2 + 10;
                    float min_y = platform_pos.Y + (platform_size.Height + bird_size.Height) / 2 - platformTopPadding;

                    if (bird_pos.X > max_x &&
                       bird_pos.X < min_x &&
                       bird_pos.Y > platform_pos.Y &&
                       bird_pos.Y < min_y)
                    {
                        Jump();
                    }
                }

                if (bird_pos.Y < -bird_size.Height / 2)
                {
                    ShowHighScores();
                }

            }
            else if (bird_pos.Y > 240)
            {

                float delta = bird_pos.Y - 240;
                bird_pos.Y = 240;

                currentPlatformY -= delta;


                for (t = (int)Tags.CloudsStart; t < (int)Tags.CloudsStart + numClouds; t++)
                {
                    var cloud = batchnode.GetChildByTag(t) as CCSprite;
                    var pos = cloud.Position;
                    pos.Y -= delta * cloud.ScaleY * 0.8f;
                    if (pos.Y < -cloud.ContentSize.Height / 2)
                    {
                        currentCloudTag = t;
                        ResetCloud();

                    }
                    else
                    {
                        cloud.Position = pos;
                    }
                }


                for (t = (int)Tags.PlatformsStart; t < (int)Tags.PlatformsStart + numPlatforms; t++)
                {
                    var platform = batchnode.GetChildByTag(t) as CCSprite;
                    var pos = platform.Position;
                    pos = new CCPoint(pos.X, pos.Y - delta);
                    if (pos.Y < -platform.ContentSize.Height / 2)
                    {
                        currentPlatformTag = t;
                        ResetPlatform();
                    }
                    else
                    {
                        platform.Position = pos;
                    }
                }

                if (bonus.Visible)
                {
                    var pos = bonus.Position;
                    pos.Y -= delta;
                    if (pos.Y < -bonus.ContentSize.Height / 2)
                    {
                        ResetBonus();
                        //[self resetBonus];
                    }
                    else
                    {
                        bonus.Position = pos;
                    }
                }

                score += (int)delta;

                var scoreLabel = GetChildByTag((int)Tags.ScoreLabel) as CCLabelBMFont;
                scoreLabel.Text = score.ToString();
            }

            bird.Position = bird_pos;

            if (particles != null)
            {
                var particle_pos = new CCPoint(bird_pos.X, bird_pos.Y - 17);
                particles.Position = particle_pos;
            }
        }
예제 #4
0
        public TMXReadWriteTest() : base("TileMaps/orthogonal-test2")
        {
            m_gid = CCTileGidAndFlags.EmptyTile;

            CCTileMapLayer layer = tileMap.LayerNamed("Layer 0");
            layer.Antialiased = true;

            tileMap.Scale = (1);

            CCSprite tile0 = layer.ExtractTile(1, 63);
            CCSprite tile1 = layer.ExtractTile(2, 63);
            CCSprite tile2 = layer.ExtractTile(3, 62); //new CCPoint(1,62));
            CCSprite tile3 = layer.ExtractTile(2, 62);
            tile0.AnchorPoint = (new CCPoint(0.5f, 0.5f));
            tile1.AnchorPoint = (new CCPoint(0.5f, 0.5f));
            tile2.AnchorPoint = (new CCPoint(0.5f, 0.5f));
            tile3.AnchorPoint = (new CCPoint(0.5f, 0.5f));

            CCMoveBy move = new CCMoveBy (0.5f, new CCPoint(0, 160));
            CCRotateBy rotate = new CCRotateBy (2, 360);
            CCScaleBy scale = new CCScaleBy(2, 5);
            CCFadeOut opacity = new CCFadeOut  (2);
            CCFadeIn fadein = new CCFadeIn  (2);
            CCScaleTo scaleback = new CCScaleTo(1, 1);
            CCCallFuncN finish = new CCCallFuncN(removeSprite);
			CCSequence sequence = new CCSequence(move, rotate, scale, opacity, fadein, scaleback, finish);

			tile0.RunAction(sequence);
			tile1.RunAction(sequence);
			tile2.RunAction(sequence);
			tile3.RunAction(sequence);


            m_gid = layer.TileGIDAndFlags(0, 63);

            Schedule(updateCol, 2.0f);
            Schedule(repaintWithGID, 2.0f);
            Schedule(removeTiles, 1.0f);


            m_gid2 = CCTileGidAndFlags.EmptyTile;
        }
예제 #5
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);
		}
예제 #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);
        }
예제 #7
0
        public override void OnEnter()
        {
            base.OnEnter(); 

            CenterSprites(3);

            var actionTo = new CCScaleTo(2, 0.5f);
            var actionBy = new CCScaleBy(2, 1, 10);
            var actionBy2 = new CCScaleBy(2, 5f, 1.0f);

            Grossini.RunAction(actionTo);
            Tamara.RunAction(new CCSequence(actionBy, actionBy.Reverse()));
            Kathia.RunAction(new CCSequence(actionBy2, actionBy2.Reverse()));
        }
예제 #8
0
 void scaleButtonTo(float scale)
 {
     var action = new CCScaleTo(0.1f, scale);
     action.Tag = 900;
     StopAction(900);
     RunAction(action);
 }
예제 #9
0
        public TMXReadWriteTest()
        {
            m_gid = 0;

            CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/orthogonal-test2");
            AddChild(map, 0, kTagTileMap);

            CCTMXLayer layer = map.LayerNamed("Layer 0");
			layer.IsAntialiased = true;

            map.Scale = (1);

            CCSprite tile0 = layer.TileAt(new CCPoint(1, 63));
            CCSprite tile1 = layer.TileAt(new CCPoint(2, 63));
            CCSprite tile2 = layer.TileAt(new CCPoint(3, 62)); //new CCPoint(1,62));
            CCSprite tile3 = layer.TileAt(new CCPoint(2, 62));
            tile0.AnchorPoint = (new CCPoint(0.5f, 0.5f));
            tile1.AnchorPoint = (new CCPoint(0.5f, 0.5f));
            tile2.AnchorPoint = (new CCPoint(0.5f, 0.5f));
            tile3.AnchorPoint = (new CCPoint(0.5f, 0.5f));

            CCMoveBy move = new CCMoveBy (0.5f, new CCPoint(0, 160));
            CCRotateBy rotate = new CCRotateBy (2, 360);
            CCScaleBy scale = new CCScaleBy(2, 5);
            CCFadeOut opacity = new CCFadeOut  (2);
            CCFadeIn fadein = new CCFadeIn  (2);
            CCScaleTo scaleback = new CCScaleTo(1, 1);
            CCCallFuncN finish = new CCCallFuncN(removeSprite);
			CCSequence sequence = new CCSequence(move, rotate, scale, opacity, fadein, scaleback, finish);

			tile0.RunAction(sequence);
			tile1.RunAction(sequence);
			tile2.RunAction(sequence);
			tile3.RunAction(sequence);


            m_gid = layer.TileGIDAt(new CCPoint(0, 63));
            ////----UXLOG("Tile GID at:(0,63) is: %d", m_gid);

            Schedule(updateCol, 2.0f);
            Schedule(repaintWithGID, 2.0f);
            Schedule(removeTiles, 1.0f);

            ////----UXLOG("++++atlas quantity: %d", layer.textureAtlas().getTotalQuads());
            ////----UXLOG("++++children: %d", layer.getChildren().count() );

            m_gid2 = 0;
        }
예제 #10
0
 void OnTouchesEnded(List<CCTouch> touches, CCEvent touchEvent)
 {
     if (touches.Count > 0)
     {
     }
     if (lastFrequencyKnobTouch != null)
     {
         lastFrequencyKnobTouch = null;
         lastFreqKnobTouchY = 0;
         lastFreqKnobTouchX = 0;
         var action = new CCScaleTo(0.1f, 1.0f);
         frequencyKnob.RunActions(action);
     }
 }
예제 #11
0
 private void OnTouchesBegan(List<CCTouch> ccTouches, CCEvent ccEvent)
 {
     foreach (CCTouch touch in ccTouches)
     {
         if (touch != null)
         {
             CCPoint tap = touch.Location;
             if (frequencyKnob.BoundingBox.ContainsPoint(tap))
             {
                 lastFrequencyKnobTouch = touch;
                 lastFreqKnobTouchY = (int)lastFrequencyKnobTouch.Location.Y;
                 lastFreqKnobTouchX = (int)lastFrequencyKnobTouch.Location.X;
                 var action = new CCScaleTo(0.1f, 0.9f);
                 frequencyKnob.RunActions(action);
             }
         }
     }
 }
예제 #12
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)));
        }
예제 #13
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);
			}

		}