public override void Unselected()
        {
            base.Unselected();
            if (m_pNormalImage != null)
            {
                m_pNormalImage.Visible = true;

                if (m_pSelectedImage != null)
                {
                    m_pSelectedImage.Visible = false;
                }
                if (ZoomBehaviorOnTouch)
                {
                    StopActionByTag(unchecked ((int)kZoomActionTag));
                    CCAction zoomAction = new CCScaleTo(0.1f, m_fOriginalScale);
                    zoomAction.Tag = unchecked ((int)kZoomActionTag);
                    RunAction(zoomAction);
                }

                if (m_pDisabledImage != null)
                {
                    m_pDisabledImage.Visible = false;
                }
            }
        }
 public override void Unselected()
 {
     base.Unselected();
     m_pSubItems[m_uSelectedIndex].Unselected();
     if (ZoomBehaviorOnTouch)
     {
         m_pSubItems[m_uSelectedIndex].StopActionByTag(unchecked ((int)kZoomActionTag));
         CCAction zoomAction = new CCScaleTo(0.1f, m_fOriginalScale);
         zoomAction.Tag = unchecked ((int)kZoomActionTag);
         m_pSubItems[m_uSelectedIndex].RunAction(zoomAction);
     }
 }
Beispiel #3
0
 public override void Unselected()
 {
     // subclass to change the default action
     if (m_bIsEnabled)
     {
         base.Unselected();
         StopActionByTag(unchecked ((int)kZoomActionTag));
         CCAction zoomAction = new CCScaleTo(0.1f, m_fOriginalScale);
         zoomAction.Tag = unchecked ((int)kZoomActionTag);
         RunAction(zoomAction);
     }
 }
        public void addSprite()
        {
            // adicionando o sprite ao lazyLayer, centralizado e usando o arquivo .png como  fonte.
            CCSprite sprite = new CCSprite("hand.png");
            sprite.Position = CCDirector.SharedDirector.WinSize.Center;
            // escalona o Sprite para ter metade de seu tamanho nominal
            sprite.Scale = 0.5f;
            // gira o Sprite em 180 graus.
            sprite.Rotation= 180;

            this.AddChild(sprite, 0);

            var rotateToA = new CCRotateTo(1, 360);
            var scaleToA = new CCScaleTo(2, 1, 1);

            // executa uma sequência de ações diretamente no this.sprite
            sprite.RunAction(new CCSequence(rotateToA, scaleToA));
        }
Beispiel #5
0
        public override void OnEnter()
        {
            base.OnEnter();

            this.TouchEnabled = true;

            CCSize s = CCDirector.SharedDirector.WinSize;
            CCLayerColor layer = new CCLayerColor(new CCColor4B(0xFF, 0x00, 0x00, 0x80), s.Width * 0.75f, s.Height * 0.75f);

            layer.IgnoreAnchorPointForPosition = false;
            layer.Position = (new CCPoint(s.Width / 2, s.Height / 2));
            AddChild(layer, 1, kTagLayer);
            //
            // Add two labels using BM label class
            // CCLabelBMFont
            CCLabelBMFont label1 = new CCLabelBMFont("LABEL1", "fonts/konqa32.fnt");
            layer.AddChild(label1);
            label1.Position = new CCPoint(layer.ContentSize.Width / 2, layer.ContentSize.Height * 0.75f);
            CCLabelBMFont label2 = new CCLabelBMFont("LABEL2", "fonts/konqa32.fnt");
            layer.AddChild(label2);
            label2.Position = new CCPoint(layer.ContentSize.Width / 2, layer.ContentSize.Height * 0.25f);
            //
            // Do the sequence of actions in the bug report
            float waitTime = 3f;
            float runTime = 12f;
            layer.Visible = false;
            CCHide hide = new CCHide();
            CCScaleTo scaleTo1 = new CCScaleTo(0.0f, 0.0f);
            CCShow show = new CCShow();
            CCDelayTime delay = new CCDelayTime (waitTime);
            CCScaleTo scaleTo2 = new CCScaleTo(runTime * 0.25f, 1.2f);
            CCScaleTo scaleTo3 = new CCScaleTo(runTime * 0.25f, 0.95f);
            CCScaleTo scaleTo4 = new CCScaleTo(runTime * 0.25f, 1.1f);
            CCScaleTo scaleTo5 = new CCScaleTo(runTime * 0.25f, 1.0f);

            CCFiniteTimeAction seq = new CCSequence(hide, scaleTo1, show, delay, scaleTo2, scaleTo3, scaleTo4, scaleTo5);

            layer.RunAction(seq);


        }
        public override void Selected()
        {
            base.Selected();
            m_pSubItems[m_uSelectedIndex].Selected();
            if (ZoomBehaviorOnTouch)
            {
                CCAction action = m_pSubItems[m_uSelectedIndex].GetActionByTag(unchecked ((int)kZoomActionTag));
                if (action != null)
                {
                    StopAction(action);
                }
                else
                {
                    m_fOriginalScale = Scale;
                }

                CCAction zoomAction = new CCScaleTo(0.1f, m_fOriginalScale * 1.2f);
                zoomAction.Tag = unchecked ((int)kZoomActionTag);
                m_pSubItems[m_uSelectedIndex].RunAction(zoomAction);
            }
        }
Beispiel #7
0
        public override void Selected()
        {
            // subclass to change the default action
            if (m_bIsEnabled)
            {
                base.Selected();

                CCAction action = GetActionByTag(unchecked ((int)kZoomActionTag));
                if (action != null)
                {
                    StopAction(action);
                }
                else
                {
                    m_fOriginalScale = Scale;
                }

                CCAction zoomAction = new CCScaleTo(0.1f, m_fOriginalScale * 1.2f);
                zoomAction.Tag = unchecked ((int)kZoomActionTag);
                RunAction(zoomAction);
            }
        }
        public override void OnEnter()
        {
            base.OnEnter();

            m_pInScene.Scale  = 0.001f;
            m_pOutScene.Scale = (1.0f);

            m_pInScene.AnchorPoint  = new CCPoint(2 / 3.0f, 0.5f);
            m_pOutScene.AnchorPoint = new CCPoint(1 / 3.0f, 0.5f);

            CCActionInterval scaleOut = new CCScaleTo(m_fDuration, 0.01f);
            CCActionInterval scaleIn  = new CCScaleTo(m_fDuration, 1.0f);

            m_pInScene.RunAction(EaseAction(scaleIn));
            m_pOutScene.RunAction
            (
                CCSequence.FromActions
                (
                    EaseAction(scaleOut),
                    new CCCallFunc((Finish))
                )
            );
        }
        public override void OnEnter()
        {
            base.OnEnter();

            m_pInScene.Scale = 0.001f;
            m_pOutScene.Scale = (1.0f);

            m_pInScene.AnchorPoint = new CCPoint(2 / 3.0f, 0.5f);
            m_pOutScene.AnchorPoint = new CCPoint(1 / 3.0f, 0.5f);

            CCActionInterval scaleOut = new CCScaleTo(m_fDuration, 0.01f);
            CCActionInterval scaleIn = new CCScaleTo(m_fDuration, 1.0f);

            m_pInScene.RunAction(EaseAction(scaleIn));
            m_pOutScene.RunAction
                (
                    new CCSequence
                        (
                            EaseAction(scaleOut),
                            new CCCallFunc((Finish))
                        )
                );
        }
Beispiel #10
0
        public override void Selected()
        {
            // subclass to change the default action
            if (m_bIsEnabled)
            {
                base.Selected();

                CCAction action = GetActionByTag(unchecked((int) kZoomActionTag));
                if (action != null)
                {
                    StopAction(action);
                }
                else
                {
                    m_fOriginalScale = Scale;
                }

                CCAction zoomAction = new CCScaleTo(0.1f, m_fOriginalScale * 1.2f);
                zoomAction.Tag = unchecked((int) kZoomActionTag);
                RunAction(zoomAction);
            }
        }
Beispiel #11
0
 public override void Unselected()
 {
     // subclass to change the default action
     if (m_bIsEnabled)
     {
         base.Unselected();
         StopActionByTag(unchecked((int) kZoomActionTag));
         CCAction zoomAction = new CCScaleTo(0.1f, m_fOriginalScale);
         zoomAction.Tag = unchecked((int) kZoomActionTag);
         RunAction(zoomAction);
     }
 }
Beispiel #12
0
 public override void Update(float dt)
 {
     elapsed += dt;
     if (elapsed > 1f)
     {
         elapsed = 0f;
         // CCLabelBMFont
         if (label1 != null)
         {
             RemoveChild(label1);
         }
         CCNode node = new CCNode();
         CCSize s = CCDirector.SharedDirector.WinSize;
         float x = s.Width * CCMacros.CCRandomBetween0And1();
         float y = s.Height * CCMacros.CCRandomBetween0And1();
         label1 = new CCLabelBMFont(string.Format("{0:N2},{1:N2} @ Mem Leak Ctor", x, y), "fonts/konqa32.fnt", 255f, CCTextAlignment.Right, CCPoint.Zero);
         node.AddChild(label1);
         label1.Position = new CCPoint(x, y);
         AddChild(node);
         label1 = node;
         // Start - test case for memory leak mentioned at https://cocos2dxna.codeplex.com/discussions/544032
         node.Scale = 2f;
         //--> This action causes the leak
         CCScaleTo acScale = new CCScaleTo(0.1f, 1);
         CCDelayTime acShow = new CCDelayTime(0.1f);
         CCSplitRows acFadeOut = new CCSplitRows(0.1f, 20);
         CCRemoveSelf acRemove = new CCRemoveSelf(true);
         CCSequence seq = new CCSequence(acScale, acShow, acFadeOut, acRemove);
         node.RunAction(seq);
     }
 }
Beispiel #13
0
        public override void OnEnter()
        {

            base.OnEnter();

            m_tamara.RemoveFromParentAndCleanup(true);
            m_grossini.RemoveFromParentAndCleanup(true);
            m_kathia.RemoveFromParentAndCleanup(true);

			// Get window size so that we can center the box layer
			var winSize = CCDirector.SharedDirector.WinSize;

			var boxSize = new CCSize(100.0f, 100.0f);

            var box = new CCLayerColor(new CCColor4B(255, 255, 0, 255));
            box.AnchorPoint = new CCPoint(0, 0);
			box.Position = new CCPoint(winSize.Center.X - (boxSize.Width / 2), winSize.Center.Y - (boxSize.Height / 2));
            box.ContentSize = boxSize;

            var uL = new CCLayerColor(new CCColor4B(255, 0, 0, 255));
            box.AddChild(uL);
            uL.ContentSize = new CCSize(markrside, markrside);
            uL.Position = new CCPoint(0.0f, boxSize.Height - markrside);
            uL.AnchorPoint = new CCPoint(0, 0);

            var uR = new CCLayerColor(new CCColor4B(0, 0, 255, 255));
            box.AddChild(uR);
            uR.ContentSize = new CCSize(markrside, markrside);
            uR.Position = new CCPoint(boxSize.Width - markrside, boxSize.Height - markrside);
            uR.AnchorPoint = new CCPoint(0, 0);
            AddChild(box);

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

            var actionScaleToBack = new CCScaleTo(2, 1.0f, 1.0f);
            var rotateToBack = new CCRotateTo (2, 0);
            var actionToBack = new CCSkewTo (2, 0, 0);

            box.RunAction(new CCSequence(actionTo, actionToBack));
            box.RunAction(new CCSequence(rotateTo, rotateToBack));
            box.RunAction(new CCSequence(actionScaleTo, actionScaleToBack));
        }
Beispiel #14
0
        public override void Unselected()
        {
            base.Unselected();
            if (m_pNormalImage != null)
            {
                m_pNormalImage.Visible = true;

                if (m_pSelectedImage != null)
                {
                    m_pSelectedImage.Visible = false;
                }
                if (ZoomBehaviorOnTouch)
                {
                    StopActionByTag(unchecked((int)kZoomActionTag));
                    CCAction zoomAction = new CCScaleTo(0.1f, m_fOriginalScale);
                    zoomAction.Tag = unchecked((int)kZoomActionTag);
                    RunAction(zoomAction);
                }

                if (m_pDisabledImage != null)
                {
                    m_pDisabledImage.Visible = false;
                }
            }
        }
Beispiel #15
0
 public override void Unselected()
 {
     base.Unselected();
     m_pSubItems[m_uSelectedIndex].Unselected();
     if (ZoomBehaviorOnTouch)
     {
         m_pSubItems[m_uSelectedIndex].StopActionByTag(unchecked((int)kZoomActionTag));
         CCAction zoomAction = new CCScaleTo(0.1f, m_fOriginalScale);
         zoomAction.Tag = unchecked((int)kZoomActionTag);
         m_pSubItems[m_uSelectedIndex].RunAction(zoomAction);
     }
 }
Beispiel #16
0
        public override void Selected()
        {
            base.Selected();
            m_pSubItems[m_uSelectedIndex].Selected();
            if (ZoomBehaviorOnTouch)
            {
                CCAction action = m_pSubItems[m_uSelectedIndex].GetActionByTag(unchecked((int)kZoomActionTag));
                if (action != null)
                {
                    StopAction(action);
                }
                else
                {
                    m_fOriginalScale = Scale;
                }

                CCAction zoomAction = new CCScaleTo(0.1f, m_fOriginalScale * 1.2f);
                zoomAction.Tag = unchecked((int)kZoomActionTag);
                m_pSubItems[m_uSelectedIndex].RunAction(zoomAction);
            }
        }
Beispiel #17
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);
            var actionByBack = actionBy.Reverse();

            m_grossini.RunAction(actionTo);
            m_tamara.RunAction(new CCSequence(actionBy, actionBy.Reverse()));
            m_kathia.RunAction(new CCSequence(actionBy2, actionBy2.Reverse()));
        }
Beispiel #18
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)));

        }
Beispiel #19
0
        public TMXReadWriteTest()
        {
            m_gid = 0;

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

            CCTMXLayer layer = map.LayerNamed("Layer 0");
            layer.Texture.SetAntiAliasTexParameters();

            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 seq0 = new CCSequence(move, rotate, scale, opacity, fadein, scaleback, finish);
            var seq1 = (CCActionInterval) (seq0.Copy());
            var seq2 = (CCActionInterval) (seq0.Copy());
            var seq3 = (CCActionInterval) (seq0.Copy());

            tile0.RunAction(seq0);
            tile1.RunAction(seq1);
            tile2.RunAction(seq2);
            tile3.RunAction(seq3);


            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;
        }
Beispiel #20
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.SetString(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;
			}
		}