当前位置: 首页>>代码示例>>C#>>正文


C# CocosSharp.CCMenu类代码示例

本文整理汇总了C#中CocosSharp.CCMenu的典型用法代码示例。如果您正苦于以下问题:C# CCMenu类的具体用法?C# CCMenu怎么用?C# CCMenu使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CCMenu类属于CocosSharp命名空间,在下文中一共展示了CCMenu类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MenuLayerPriorityTest

        public MenuLayerPriorityTest()
        {
            // Testing empty menu
            m_pMenu1 = new CCMenu();
            m_pMenu2 = new CCMenu();


            // Menu 1
            CCMenuItemFont item1 = new CCMenuItemFont("Return to Main Menu", menuCallback);
            CCMenuItemFont item2 = new CCMenuItemFont("Disable menu for 5 seconds", disableMenuCallback);


            m_pMenu1.AddChild(item1);
            m_pMenu1.AddChild(item2);

            m_pMenu1.AlignItemsVertically(2);

            AddChild(m_pMenu1);

            // Menu 2
            m_bPriority = true;
            //CCMenuItemFont.setFontSize(48);
            item1 = new CCMenuItemFont("Toggle priority", togglePriorityCallback);
            item1.Scale = 1.5f;
            item1.Color = new CCColor3B(0, 0, 255);
            m_pMenu2.AddChild(item1);
            AddChild(m_pMenu2);
        }
开发者ID:h7ing,项目名称:CocosSharp,代码行数:28,代码来源:MenuLayerPriorityTest.cs

示例2: NodeToWorld3D

		public NodeToWorld3D()
		{
			//
			// This code tests that nodeToParent works OK:
			//  - It tests different anchor Points
			//  - It tests different children anchor points

			parent = new CCNode();
			parent.AnchorPoint = new CCPoint(0.5f, 0.5f);
			AddChild(parent);

			back = new CCSprite(TestResource.s_back3);
			parent.AddChild(back, -10);
			back.AnchorPoint = CCPoint.Zero;


			var item = new CCMenuItemImage(TestResource.s_PlayNormal, TestResource.s_PlaySelect);
			menu = new CCMenu(item);
			menu.AlignItemsVertically();

			back.AddChild(menu);

			item.RepeatForever(CocosNodeTestStaticLibrary.nodeRotate);

			back.RepeatForever(CocosNodeTestStaticLibrary.nodeMove, CocosNodeTestStaticLibrary.nodeMove.Reverse());

			parent.RunAction (CocosNodeTestStaticLibrary.nodeOrbit);
		}
开发者ID:h7ing,项目名称:CocosSharp,代码行数:28,代码来源:NodeToWorld.cs

示例3: OnEnter

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

            var s = Layer.VisibleBoundsWorldspace.Size;

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

            var pMainItem = new CCMenuItemFont("Back", toMainLayer);
            pMainItem.Position = new CCPoint(s.Width - 50, 25);
            var pMenu = new CCMenu(pMainItem);
            pMenu.Position = new CCPoint(0, 0);

            if (m_bControlMenuVisible)
            {
                var item1 = new CCMenuItemImage("Images/b1", "Images/b2", backCallback);
                var item2 = new CCMenuItemImage("Images/r1", "Images/r2", restartCallback);
                var item3 = new CCMenuItemImage("Images/f1", "Images/f2", nextCallback);
                item1.Position = new CCPoint(s.Width / 2 - 100, 30);
                item2.Position = new CCPoint(s.Width / 2, 30);
                item3.Position = new CCPoint(s.Width / 2 + 100, 30);

                pMenu.AddChild(item1, PerformanceTestScene.kItemTagBasic);
                pMenu.AddChild(item2, PerformanceTestScene.kItemTagBasic);
                pMenu.AddChild(item3, PerformanceTestScene.kItemTagBasic);
            }
            AddChild(pMenu);
        }
开发者ID:KerwinMa,项目名称:CocosSharp,代码行数:29,代码来源:PerformBasicLayer.cs

示例4: InitTableViewTestLayer

        private bool InitTableViewTestLayer()
        {

            var winSize = Layer.VisibleBoundsWorldspace.Size;

            var tableView = new CCTableView(this, new CCSize(250, 60));
            tableView.Direction = CCScrollViewDirection.Horizontal;
            tableView.Position = new CCPoint(20, winSize.Height / 2 - 30);
            tableView.Delegate = this;
            this.AddChild(tableView);
            tableView.ReloadData();

            tableView = new CCTableView(this, new CCSize(60, 280));
            tableView.Direction = CCScrollViewDirection.Vertical;
            tableView.Position = new CCPoint(winSize.Width - 150, winSize.Height / 2 - 120);
            tableView.Delegate = this;
            tableView.VerticalFillOrder = CCTableViewVerticalFillOrder.FillTopDown;
            this.AddChild(tableView);
            tableView.ReloadData();

            // Back Menu
            var itemBack = new CCMenuItemFont("Back", toExtensionsMainLayer);
            itemBack.Position = new CCPoint(winSize.Width - 50, 25);
            var menuBack = new CCMenu(itemBack);
            menuBack.Position = CCPoint.Zero;
            AddChild(menuBack);

            return true;
        }
开发者ID:netonjm,项目名称:CocosSharp,代码行数:29,代码来源:TableViewTestScene.cs

示例5: OnEnter

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

            // Testing empty menu
            menu1 = new CCMenu();
            menu2 = new CCMenu();


            // Menu 1
            var item1 = new CCMenuItemFont("Return to Main Menu", menuCallback);
            var item2 = new CCMenuItemFont("Disable menu for 5 seconds", disableMenuCallback);


            menu1.AddChild(item1);
            menu1.AddChild(item2);

            menu1.AlignItemsVertically(2);

            AddChild(menu1);

            // Menu 2
            priority = true;
            //CCMenuItemFont.setFontSize(48);
            item1 = new CCMenuItemFont("Toggle priority", togglePriorityCallback);
            item1.Scale = 1.5f;
            item1.Color = new CCColor3B(0, 0, 255);
            menu2.AddChild(item1);
            AddChild(menu2);
        }
开发者ID:KevinHeyer,项目名称:CocosSharp,代码行数:30,代码来源:MenuLayerPriorityTest.cs

示例6: reset

        public void reset()
        {

            int localtag = 0;
            localtag++;

            // TO TRIGGER THE BUG:
            // remove the itself from parent from an action
            // The menu will be removed, but the instance will be alive
            // and then a new node will be allocated occupying the memory.
            // => CRASH BOOM BANG
            CCNode node = GetChildByTag(localtag - 1);
            CCLog.Log("Menu: %p", node);
            RemoveChild(node, false);
            //	[self removeChildByTag:localtag-1 cleanup:NO];

            CCMenuItem item1 = new CCMenuItemFont("One", menuCallback);
            CCLog.Log("MenuItemFont: %p", item1);
            CCMenuItem item2 = new CCMenuItemFont("Two", menuCallback);
            CCMenu menu = new CCMenu(item1, item2);
            menu.AlignItemsVertically();

            float x = CCRandom.Next() * 50;
            float y = CCRandom.Next() * 50;
            menu.Position = menu.Position + new CCPoint(x, y);
            AddChild(menu, 0, localtag);

            //[self check:self];
        }
开发者ID:KerwinMa,项目名称:CocosSharp,代码行数:29,代码来源:Bug422Layer.cs

示例7: OnEnter

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

            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            var label = new CCLabel(title(), "arial", 26, CCLabelFormat.SpriteFont);
            AddChild(label, 1);
            label.Position = (new CCPoint(s.Width / 2, s.Height - 50));

            string strSubTitle = subtitle();
            if (strSubTitle.Length > 0)
            {
                var l = new CCLabel(strSubTitle, "Thonburi", 16, CCLabelFormat.SpriteFont);
                AddChild(l, 1);
                l.Position = (new CCPoint(s.Width / 2, s.Height - 80));
            }

            CCMenuItemImage item1 = new CCMenuItemImage(TestResource.s_pPathB1, TestResource.s_pPathB2, backCallback);
            CCMenuItemImage item2 = new CCMenuItemImage(TestResource.s_pPathR1, TestResource.s_pPathR2, restartCallback);
            CCMenuItemImage item3 = new CCMenuItemImage(TestResource.s_pPathF1, TestResource.s_pPathF2, nextCallback);

            CCMenu menu = new CCMenu(item1, item2, item3);

            menu.Position = (new CCPoint(0, 0));
            item1.Position = (new CCPoint(s.Width / 2 - 100, 30));
            item2.Position = (new CCPoint(s.Width / 2, 30));
            item3.Position = (new CCPoint(s.Width / 2 + 100, 30));
            AddChild(menu, 1);
        }
开发者ID:haithemaraissia,项目名称:CocosSharp,代码行数:30,代码来源:ZwoptexTest.cs

示例8: OnEnter

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

            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            CCLabelTtf label = new CCLabelTtf(title(), "arial", 40);
            label.AnchorPoint = new CCPoint (0.5f, 0.5f);
            AddChild(label, 1);
            label.Position = (new CCPoint(s.Width / 2, s.Height - 50));

            CCMenuItemImage item1 = new CCMenuItemImage(s_pPathB1, s_pPathB2, backCallback);
            CCMenuItemImage item2 = new CCMenuItemImage(s_pPathR1, s_pPathR2, restartCallback);
            CCMenuItemImage item3 = new CCMenuItemImage(s_pPathF1, s_pPathF2, nextCallback);

            CCMenu menu = new CCMenu(item1, item2, item3);

            float padding = 10.0f;
            float halfRestartWidth = item2.ContentSize.Width / 2.0f;

            menu.Position = (new CCPoint(0, 0));

            // Anchor point of menu items is 0.5, 0.5 by default
            item1.Position = (new CCPoint(s.Width / 2 - item1.ContentSize.Width / 2.0f - halfRestartWidth - padding, item2.ContentSize.Height + padding));
            item2.Position = (new CCPoint(s.Width / 2, item2.ContentSize.Height + padding));
            item3.Position = (new CCPoint(s.Width / 2 + item3.ContentSize.Width / 2.0f + halfRestartWidth + padding, item2.ContentSize.Height + padding));

            AddChild(menu, TestScene.MENU_LEVEL);
        }
开发者ID:netonjm,项目名称:CocosSharp,代码行数:29,代码来源:ActionManagerTest.cs

示例9: InitOrientationTest

        private bool InitOrientationTest ()
        {
            bool bRet = false;
            do
            {

                CCSize s = Layer.VisibleBoundsWorldspace.Size;

                var label = new CCLabel(title(), "Arial", 26, CCLabelFormat.SpriteFont);
                AddChild(label, 1);
                label.Position = new CCPoint(s.Width / 2, s.Height - 50);

                string sSubtitle = subtitle();
                if (sSubtitle.Length > 0)
                {
                    var l = new CCLabel(sSubtitle, "Arial", 16, CCLabelFormat.SpriteFont);
                    AddChild(l, 1);
                    l.Position = new CCPoint(s.Width / 2, s.Height - 80);
                }

                CCMenuItemImage item1 = new CCMenuItemImage(TestResource.s_pPathB1, TestResource.s_pPathB2,  BackCallback);
                CCMenuItemImage item2 = new CCMenuItemImage(TestResource.s_pPathR1, TestResource.s_pPathR2,  RestartCallback);
                CCMenuItemImage item3 = new CCMenuItemImage(TestResource.s_pPathF1, TestResource.s_pPathF2,  NextCallback);

                CCMenu menu = new CCMenu(item1, item2, item3);
                menu.Position = s.Center;
                item1.Position = new CCPoint(s.Width / 2 - 100, 30);
                item2.Position = new CCPoint(s.Width / 2, 30);
                item3.Position = new CCPoint(s.Width / 2 + 100, 30);

                bRet = true;
            } while (false);

            return bRet;
        }
开发者ID:Kingwl,项目名称:CocosSharp,代码行数:35,代码来源:OrientationTest.cs

示例10: OnEnter

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

			var s = Layer.VisibleBoundsWorldspace.Size;

			var sprite = new CCSprite("Images/grossinis_sister1.png");
			sprite.Position = VisibleBoundsWorldspace.Center;
			AddChild(sprite);
			sprite.RepeatForever(rotateBy);

			// Add a menu item to resume the Scheduled actions.

			CCMenuItemFont.FontSize = 32;
			CCMenuItemFont.FontName = "MarkerFelt";
			var menu = new CCMenu(
				new CCMenuItemFont("Resume", resume)
			);

			menu.AlignItemsVertically(4);
			menu.Position = new CCPoint(s.Width / 2, s.Height / 4);
			AddChild(menu);


			Schedule ();
			Schedule (tick1, 0.5f);
			Schedule (tick2, 1.0f);
			Schedule (pause, 3.0f, 0, 0);
		}
开发者ID:h7ing,项目名称:CocosSharp,代码行数:29,代码来源:SchedulerPauseResume.cs

示例11: OnEnter

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

            var origin = Layer.VisibleBoundsWorldspace.Size;

            var label1 = new CCLabel(string.Empty, "debuguncompressed", 0, CCLabelFormat.SpriteFont);

            var texture = label1.TextureAtlas != null ? label1.TextureAtlas.Texture : null;

            if (texture != null) {
                spriteFontNode = new CCSprite (texture);
                spriteFontNode.Scale = 2;
            }
            else
            {
                spriteFontNode = new CCLabel("Texture can not be loaded", "arial", 24, CCLabelFormat.SpriteFont);
            }
            //spriteFontNode.Color = CCColor3B.Magenta;
            spriteFontNode.Position = origin.Center;


            AddChild (spriteFontNode);

            var itemUncompressed = new CCMenuItemLabel(new CCLabel("Uncompressed", "fonts/arial", 24, CCLabelFormat.SpriteFont));
            var itemCompressed = new CCMenuItemLabel(new CCLabel("Compressed", "fonts/arial", 24, CCLabelFormat.SpriteFont));
            itemUncompressed.AnchorPoint = CCPoint.AnchorMiddleLeft;
            itemCompressed.AnchorPoint = CCPoint.AnchorMiddleLeft;
            var mi1 = new CCMenuItemToggle(OnToggle, itemUncompressed, itemCompressed);
            var menu = new CCMenu(mi1);

            AddChild(menu);
            menu.Position = VisibleBoundsWorldspace.Left();
        }
开发者ID:haithemaraissia,项目名称:CocosSharp,代码行数:34,代码来源:LabelFSTextureView.cs

示例12: LabelTTFTest

        public LabelTTFTest()
        {

            CCMenuItemFont.FontSize = 32;
            CCMenuItemFont.FontName = "MarkerFelt";

            menuLeft = new CCMenu(
                new CCMenuItemFont("Left", setAlignmentLeft),
                new CCMenuItemFont("Center", setAlignmentCenter),
                new CCMenuItemFont("Right", setAlignmentRight)
            );
            menuLeft.AlignItemsVertically(4);

            AddChild(menuLeft);

            menuRight = new CCMenu(
                new CCMenuItemFont("Top", setAlignmentTop),
                new CCMenuItemFont("Middle", setAlignmentMiddle),
                new CCMenuItemFont("Bottom", setAlignmentBottom)
            );
            menuRight.AlignItemsVertically(4);

            AddChild(menuRight);

        }
开发者ID:h7ing,项目名称:CocosSharp,代码行数:25,代码来源:LabelTTFTest.cs

示例13: HighScoreLayer

		public HighScoreLayer (int score): base()
		{
			currentScore = score;


			var batchnode = GetChildByTag ((int)Tags.SpriteManager) as CCSpriteBatchNode;
			var title = new CCSprite(batchnode.Texture,new CCRect(608,192,225,57));
            title.Position=new CCPoint(160,240);
			batchnode.AddChild (title);



			var button1 = new CCMenuItemImage("Images/playAgainButton", "Images/playAgainButton",
                new Action<object>(delegate(object o) {
			 	 Director.ReplaceScene(new CCTransitionFade(.5f, GameLayer.Scene, new CCColor3B(255,255,255)));
                }));
			var button2 = new CCMenuItemImage("Images/changePlayerButton", "Images/changePlayerButton", new Action<object>(delegate (object sender) {
                // do nothing
			}));
			var menu = new CCMenu(button1,button2);
            menu.Position=new CCPoint(160,58);
			menu.AlignItemsVertically(9);

			AddChild (menu);
			

		}
开发者ID:h7ing,项目名称:CocosSharp,代码行数:27,代码来源:HighScoreLayer.cs

示例14: OnEnter

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

            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            Box2DView view = Box2DView.viewWithEntryID(m_entryID);
            AddChild(view, 0, kTagBox2DNode);
            view.Scale = 8;
            view.AnchorPoint = new CCPoint(0, 0);
            view.Position = new CCPoint(s.Width / 2, s.Height / 4);

            //#if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE)
            //    CCLabelBMFont* label = new CCLabelBMFont(view.title().c_str(),  "fonts/arial16.fnt");
            //#else    
            CCLabelTtf label = new CCLabelTtf(view.title(), "arial", 18);
            //#endif
            AddChild(label, 1);
            label.Position = new CCPoint(s.Width / 2, s.Height - 30);

            CCMenuItemImage item1 = new CCMenuItemImage("Images/b1", "Images/b2", backCallback);
            CCMenuItemImage item2 = new CCMenuItemImage("Images/r1", "Images/r2", restartCallback);
            CCMenuItemImage item3 = new CCMenuItemImage("Images/f1", "Images/f2", nextCallback);

            CCMenu menu = new CCMenu(item1, item2, item3);

            menu.Position = CCPoint.Zero;
            item1.Position = new CCPoint(s.Width / 2 - 100, 30);
            item2.Position = new CCPoint(s.Width / 2, 30);
            item3.Position = new CCPoint(s.Width / 2 + 100, 30);

            AddChild(menu, 1);
        }
开发者ID:songfulin,项目名称:CocosSharp,代码行数:33,代码来源:MenuLayer.cs

示例15: OnEnter

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

            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            CCLabelTtf label = new CCLabelTtf(title(), "arial", 32);
            AddChild(label);
            label.Position = (new CCPoint(s.Width / 2, s.Height - 50));

            string subTitle = subtitle();
            if (!string.IsNullOrEmpty(subTitle))
            {
                CCLabelTtf l = new CCLabelTtf(subTitle, "arial", 16);
                AddChild(l, 1);
                l.Position = new CCPoint(s.Width / 2, s.Height - 80);
            }

            CCMenuItemImage item1 = new CCMenuItemImage("Images/b1", "Images/b2", backCallback);
            CCMenuItemImage item2 = new CCMenuItemImage("Images/r1", "Images/r2", restartCallback);
            CCMenuItemImage item3 = new CCMenuItemImage("Images/f1", "Images/f2", nextCallback);

            CCMenu menu = new CCMenu(item1, item2, item3);
            menu.Position = new CCPoint(0, 0);
            item1.Position = new CCPoint(s.Width / 2 - 100, 30);
            item2.Position = new CCPoint(s.Width / 2, 30);
            item3.Position = new CCPoint(s.Width / 2 + 100, 30);

            AddChild(menu, 1);
        }
开发者ID:h7ing,项目名称:CocosSharp,代码行数:30,代码来源:SchedulerTestLayer.cs


注:本文中的CocosSharp.CCMenu类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。