protected override void AddedToScene()
        {
            base.AddedToScene();

            var label = new CCLabelBMFont("Enable AtlasItem", "fonts/bitmapFontTest3.fnt");
            var item1 = new CCMenuItemLabelBMFont(label, this.menuCallback2);

            CCMenuItemFont.FontSize = 28;
            CCMenuItemFont.FontName = "arial";

            var item2 = new CCMenuItemFont("--- Go Back ---", this.menuCallback);

            // We do not have an HD version of the menuitemsprite so internally CocosSharp tries to convert our
            // rectangle coordinates passed to work with HD images so the coordinates are off.  We will just 
            // modify this here to make sure we have the correct sizes when they are passed.
            var spriteNormal = new CCSprite(s_MenuItem, new CCRect(0, 23 * 2, 115, 23));
            var spriteSelected = new CCSprite(s_MenuItem, new CCRect(0, 23 * 1, 115, 23));
            var spriteDisabled = new CCSprite(s_MenuItem, new CCRect(0, 23 * 0, 115, 23));


            var item3 = new CCMenuItemImage(spriteNormal, spriteSelected, spriteDisabled, this.menuCallback3);
            m_disabledItem = item3;
            m_disabledItem.Enabled = false;

            var menu = new CCMenu(item1, item2, item3);
            menu.Position = new CCPoint(0, 0);

            var s = Layer.VisibleBoundsWorldspace.Size;

            item1.Position = new CCPoint(s.Width / 2 - 150, s.Height / 2);
            item2.Position = new CCPoint(s.Width / 2 - 200, s.Height / 2);
            item3.Position = new CCPoint(s.Width / 2, s.Height / 2 - 100);

            var jump = new CCJumpBy (3, new CCPoint(400, 0), 50, 4);
            item2.RepeatForever(jump, jump.Reverse());

            var spin1 = new CCRotateBy (3, 360);

            item1.RepeatForever(spin1);
            item2.RepeatForever(spin1);
            item3.RepeatForever(spin1);

            AddChild(menu);
        }
Exemple #2
0
        public MenuLayer4()
        {
			CCMenuItemFont.FontSize = 18;
			CCMenuItemFont.FontName = "arial";

            CCMenuItemFont title1 = new CCMenuItemFont("Sound");
            title1.Enabled = false;

			CCMenuItemFont.FontSize = 34;
            
            CCMenuItemToggle item1 = new CCMenuItemToggle(this.menuCallback,
                new CCMenuItemFont("On"),
                new CCMenuItemFont("Off"));

			CCMenuItemFont.FontSize = 18;

			CCMenuItemFont title2 = new CCMenuItemFont("Music");
            title2.Enabled = false;

			CCMenuItemFont.FontSize = 34;
            CCMenuItemToggle item2 = new CCMenuItemToggle(this.menuCallback,
                new CCMenuItemFont("On"),
				new CCMenuItemFont("Off"));

			CCMenuItemFont.FontSize = 18;
            CCMenuItemFont title3 = new CCMenuItemFont("Quality");
            title3.Enabled = false;

			CCMenuItemFont.FontSize = 34;
            CCMenuItemToggle item3 = new CCMenuItemToggle(this.menuCallback,
                new CCMenuItemFont("High"),
                new CCMenuItemFont("Low"));
                
				CCMenuItemFont.FontSize = 18;
            CCMenuItemFont title4 = new CCMenuItemFont("Orientation");
            title4.Enabled = false;

				CCMenuItemFont.FontSize = 34;

            CCMenuItemToggle item4 = new CCMenuItemToggle(this.menuCallback,
                new CCMenuItemFont("Off"));

            item4.AddToggleMenuItems(new CCMenuItemFont ("33%"), new CCMenuItemFont ("66%"), new CCMenuItemFont ("100%"));

            // you can change the one of the items by doing this
            item4.SelectedIndex = 2;

            CCLabelBMFont label = new CCLabelBMFont("go back", "fonts/bitmapFontTest3.fnt");
            CCMenuItemLabelBMFont back = new CCMenuItemLabelBMFont(label, this.backCallback);

            CCMenu menu = new CCMenu(
                          title1, title2,
                          item1, item2,
                          title3, title4,
                          item3, item4,
				back) { Tag = 36 }; // 9 items.

            menu.AlignItemsInColumns(2, 2, 2, 2, 1);

            AddChild(menu);
        }
Exemple #3
0
        public MenuLayer1()
        {

			// Register Touch Event
			touchListener = new CCEventListenerTouchOneByOne();
			touchListener.IsSwallowTouches = true;

			touchListener.OnTouchBegan = onTouchBegan;
			touchListener.OnTouchMoved = onTouchMoved;
			touchListener.OnTouchEnded = onTouchEnded;
			touchListener.OnTouchCancelled = onTouchCancelled;

			AddEventListener(touchListener, 1);

			// We do not have an HD version of the menuitemsprite so internally CocosSharp tries to convert our
			// rectangle coordinates passed to work with HD images so the coordinates are off.  We will just 
			// modify this here to make sure we have the correct sizes when they are passed.
			CCSprite spriteNormal = new CCSprite(s_MenuItem, new CCRect(0, 23 * 2, 115, 23));
			CCSprite spriteSelected = new CCSprite(s_MenuItem, new CCRect(0, 23 * 1, 115, 23));
			CCSprite spriteDisabled = new CCSprite(s_MenuItem, new CCRect(0, 23 * 0, 115, 23));


            var item1 = new CCMenuItemImage(spriteNormal, spriteSelected, spriteDisabled, this.menuCallback);

            // Image Item
            var item2 = new CCMenuItemImage(s_SendScore, s_PressSendScore, this.menuCallback2);

            // Label Item (LabelAtlas)
            var labelAtlas = new CCLabelAtlas("0123456789", "Images/fps_Images.png", 12, 32, '.');
            var item3 = new CCMenuItemLabelAtlas(labelAtlas, this.menuCallbackDisabled);
            item3.DisabledColor = new CCColor3B(32, 32, 64);
            item3.Color = new CCColor3B(200, 200, 255);

            // Font Item
			CCMenuItemFont item4 = new CCMenuItemFont("I toggle enable items", (sender) => 
				{
					disabledItem.Enabled = !disabledItem.Enabled;

				});

            // Label Item (CCLabelBMFont)
            CCLabelBMFont label = new CCLabelBMFont("configuration", "fonts/bitmapFontTest3.fnt");
            CCMenuItemLabelBMFont item5 = new CCMenuItemLabelBMFont(label, this.menuCallbackConfig);


            // Testing issue #500
            item5.Scale = 0.8f;

			CCMenuItemFont.FontSize = 30;
            // Events
            CCMenuItemFont item6 = new CCMenuItemFont("Priority Test", menuCallbackPriorityTest);

            // Font Item
			CCMenuItemFont item7 = new CCMenuItemFont("Quit", this.onQuit);
			item7.RepeatForever(color_action, color_action.Reverse());

			menu = new CCMenu(item1, item2, item3, item4, item5, item6, item7);
			menu.AlignItemsVertically();

            disabledItem = item3;
            disabledItem.Enabled = false;

            AddChild(menu);
			menu.Scale = 0;
			menu.RunAction(new CCScaleTo(1, 1));
        }
        protected override void AddedToScene()
        {
            base.AddedToScene();

            // We do not have an HD version of the menuitemsprite so internally CocosSharp tries to convert our
            // rectangle coordinates passed to work with HD images so the coordinates are off.  We will just 
            // modify this here to make sure we have the correct sizes when they are passed.
            CCSprite spriteNormal = new CCSprite(s_MenuItem, new CCRect(0, 23 * 2, 115, 23));
            CCSprite spriteSelected = new CCSprite(s_MenuItem, new CCRect(0, 23 * 1, 115, 23));
            CCSprite spriteDisabled = new CCSprite(s_MenuItem, new CCRect(0, 23 * 0, 115, 23));


            var item1 = new CCMenuItemImage(spriteNormal, spriteSelected, spriteDisabled, this.menuCallback);

            // Image Item
            var item2 = new CCMenuItemImage(s_SendScore, s_PressSendScore, this.menuCallback2);

            // Label Item (LabelAtlas)
            var labelAtlas = new CCLabelAtlas("0123456789", "Images/fps_Images.png", 12, 32, '.');
            var item3 = new CCMenuItemLabelAtlas(labelAtlas, this.menuCallbackDisabled);
            item3.DisabledColor = new CCColor3B(32, 32, 64);
            item3.Color = new CCColor3B(200, 200, 255);

            // Font Item
            CCMenuItemFont item4 = new CCMenuItemFont("I toggle enable items", (sender) => 
                {
                    disabledItem.Enabled = !disabledItem.Enabled;

                });

            // Label Item (CCLabelBMFont)
            CCLabelBMFont label = new CCLabelBMFont("configuration", "fonts/bitmapFontTest3.fnt");
            CCMenuItemLabelBMFont item5 = new CCMenuItemLabelBMFont(label, this.menuCallbackConfig);


            // Testing issue #500
            item5.Scale = 0.8f;

            CCMenuItemFont.FontSize = 30;
            // Events
            CCMenuItemFont item6 = new CCMenuItemFont("Priority Test", menuCallbackPriorityTest);

            // Font Item
            CCMenuItemFont item7 = new CCMenuItemFont("Quit", this.onQuit);
            item7.RepeatForever(color_action, color_action.Reverse());

            menu = new CCMenu(item1, item2, item3, item4, item5, item6, item7);
            menu.AlignItemsVertically();

            disabledItem = item3;
            disabledItem.Enabled = false;

            AddChild(menu);
            menu.Scale = 0;
            menu.RunAction(new CCScaleTo(1, 1));

			// elastic effect
            CCSize s = Layer.VisibleBoundsWorldspace.Size;

			int i = 0;
			CCNode child;
			var pArray = menu.Children;
			object pObject = null;
			if (pArray.Count > 0)
			{
				for (int j = 0; j < pArray.Count; j++)
				{
					pObject = pArray[j];
					if (pObject == null)
						break;

					child = (CCNode) pObject;
					CCPoint dstPoint = child.Position;
					int offset = (int) (s.Width / 2 + 50);
					if (i % 2 == 0)
						offset = -offset;

					child.Position = new CCPoint(dstPoint.X + offset, dstPoint.Y);
					child.RunAction(new CCEaseElasticOut(new CCMoveBy(2, new CCPoint(dstPoint.X - offset, 0)), 0.35f));
					i++;

				}
			}
		}