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


C# CCMenu.AddChild方法代码示例

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


在下文中一共展示了CCMenu.AddChild方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: 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

示例4: CocosDenshionTest

        public CocosDenshionTest()
        {
            testMenu = null;
            beginPos = new CCPoint(0,0);
            soundId = 0;

            string[] testItems = {
                "Play background music",
                "Stop background music",
                "Pause background music",
                "Resume background music",
                "Rewind background music",
                "Is background music playing",
                "Play effect",
                "Play effect repeatly",
                "Stop effect",
                "Unload effect",
                "Add background music volume",
                "Sub background music volume",
                "Add effects volume",
                "Sub effects volume"
            };

            testMenu = new CCMenu(null);
            testMenuItems = new List<CCMenuItem>();

            for(int i=0; i < testItems.Count(); ++i)
            {
                CCLabelTtf label = new CCLabelTtf(testItems[i], "arial", 24);
                CCMenuItemLabelTTF menuItem = new CCMenuItemLabelTTF(label, MenuCallback);
                testMenu.AddChild(menuItem, i + 10000);
                testMenuItems.Add(menuItem);
            }

            AddChild(testMenu);

            // preload background music and effect
            CCSimpleAudioEngine.SharedEngine.PreloadBackgroundMusic(CCFileUtils.FullPathFromRelativePath(MUSIC_FILE));
            CCSimpleAudioEngine.SharedEngine.PreloadEffect(CCFileUtils.FullPathFromRelativePath(EFFECT_FILE));

            // set default volume
            CCSimpleAudioEngine.SharedEngine.EffectsVolume = 0.5f;
            CCSimpleAudioEngine.SharedEngine.BackgroundMusicVolume = 0.5f;

            Camera = AppDelegate.SharedCamera;
        }
开发者ID:netonjm,项目名称:CocosSharp,代码行数:46,代码来源:CocosDenshionTest.cs

示例5: TestController

        public TestController()
        {
            // Add close menu
            closeMenuItem = new CCMenuItemImage(TestResource.s_pPathClose, TestResource.s_pPathClose, CloseCallback);
            closeMenu = new CCMenu(closeMenuItem);

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


            #if !PSM && !WINDOWS_PHONE
            #if NETFX_CORE
            versionLabel = new CCLabel("v" + this.GetType().GetAssemblyName().Version.ToString(), "arial", 30);
            #else
            versionLabel = new CCLabel("v" + this.GetType().Assembly.GetName().Version.ToString(), "fonts/arial", 24, CCLabelFormat.SpriteFont);
            #endif
            AddChild(versionLabel, 20000);
            #endif

            // Add test list menu
            testListMenu = new CCMenu();

            var i = 0;
            foreach (var test in testCases.Keys)
            {
                var label = new CCLabel(test, "fonts/arial", 24, CCLabelFormat.SpriteFont);
                var menuItem = new CCMenuItemLabel(label, MenuCallback);

                testListMenu.AddChild(menuItem, i++ + MENU_ITEM_Z_ORDER);
                testListMenuItems.Add(menuItem);
            }

            LINE_SPACE = (int)(testListMenuItems[0].ContentSize.Height * 1.5f);

            #if XBOX || OUYA
            CCSprite sprite = new CCSprite("Images/aButton");
            AddChild(sprite, 10001);
            menuIndicator = sprite;
            #endif

            AddChild(testListMenu);
            AddChild(closeMenu, 1);
        }
开发者ID:haithemaraissia,项目名称:CocosSharp,代码行数:43,代码来源:controller.cs

示例6: OnEnter

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

			var	s = Layer.VisibleBoundsWorldspace.Size;

			var pMenu = new CCMenu();
			pMenu.Position = CCPoint.Zero;
			CCMenuItemFont.FontSize = 24;
			CCMenuItemFont.FontName = "arial";
			for (int i = 0; i < ExtensionsTestScene.TEST_MAX_COUNT; ++i)
			{
                var pItem = new CCMenuItemFont(ExtensionsTestScene.testsName[i], menuCallback);
				pItem.Position = new CCPoint(s.Width / 2, s.Height - (i + 1) * ExtensionsTestScene.LINE_SPACE);
				pMenu.AddChild(pItem, ExtensionsTestScene.kItemTagBasic + i);
			}

			AddChild(pMenu);

		}
开发者ID:haithemaraissia,项目名称:CocosSharp,代码行数:20,代码来源:ExtensionsTestMainLayer.cs

示例7: OnEnter

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

            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            CCMenu pMenu = new CCMenu(null);
            pMenu.Position = new CCPoint(0, 0);

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

            for (int i = 0; i < PerformanceTestScene.MAX_COUNT; ++i)
            {
                CCMenuItemFont pItem = new CCMenuItemFont(PerformanceTestScene.testsName[i], menuCallback);
                pItem.Position = new CCPoint(s.Width / 2, s.Height - (i + 1) * PerformanceTestScene.LINE_SPACE);
                pMenu.AddChild(pItem, PerformanceTestScene.kItemTagBasic + i);
            }

            AddChild(pMenu);
        }
开发者ID:KerwinMa,项目名称:CocosSharp,代码行数:21,代码来源:PerformanceMainLayer.cs

示例8: TestController

        public TestController()
        {
            // Add close menu
            closeMenuItem = new CCMenuItemImage(TestResource.s_pPathClose, TestResource.s_pPathClose, CloseCallback);
            closeMenu = new CCMenu(closeMenuItem);

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


            #if !PSM && !WINDOWS_PHONE
            #if NETFX_CORE
            versionLabel = new CCLabelTtf("v" + this.GetType().GetAssemblyName().Version.ToString(), "arial", 30);
            #else
            versionLabel = new CCLabelTtf("v" + this.GetType().Assembly.GetName().Version.ToString(), "arial", 30);
            #endif
            AddChild(versionLabel, 20000);
            #endif

            // Add test list menu
            testListMenu = new CCMenu();
            for (int i = 0; i < (int)(TestCases.TESTS_COUNT); ++i)
            {
                CCLabelTtf label = new CCLabelTtf(Tests.g_aTestNames[i], "arial", 50);
                CCMenuItem menuItem = new CCMenuItemLabelTTF(label, MenuCallback);

				testListMenu.AddChild(menuItem, i + MENU_ITEM_Z_ORDER);
                testListMenuItems.Add(menuItem);
            }

            #if XBOX || OUYA
            CCSprite sprite = new CCSprite("Images/aButton");
            AddChild(sprite, 10001);
            menuIndicator = sprite;
            #endif

            AddChild(testListMenu);
            AddChild(closeMenu, 1);
        }
开发者ID:h7ing,项目名称:CocosSharp,代码行数:39,代码来源:controller.cs

示例9: OnEnter

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

            CCSize s = Layer.VisibleBoundsWorldspace.Size;
            m_pItmeMenu = new CCMenu(null);

            for (int i = 0; i < BugsTestScene.MAX_COUNT; ++i)
            {
                CCMenuItemFont pItem = new CCMenuItemFont(BugsTestScene.testsName[i], menuCallback);
                pItem.Position = new CCPoint(s.Width / 2, s.Height - (i + 1) * BugsTestScene.LINE_SPACE);
                m_pItmeMenu.AddChild(pItem, BugsTestScene.kItemTagBasic + i);
            }

            m_pItmeMenu.Position = BugsTestScene.s_tCurPos;
            AddChild(m_pItmeMenu);
			// Register Touch Event
			var touchListener = new CCEventListenerTouchAllAtOnce();

			touchListener.OnTouchesBegan = onTouchesBegan;
			touchListener.OnTouchesMoved = onTouchesMoved;

            AddEventListener(touchListener);
        }
开发者ID:h7ing,项目名称:CocosSharp,代码行数:24,代码来源:BugsTestMainLayer.cs

示例10: initWithSubTest

        public void initWithSubTest(int asubtest, int nNodes)
        {
            //srandom(0);

            subtestNumber = asubtest;
            m_pSubTest = new SubTest();
            m_pSubTest.initWithSubTest(asubtest, this);

            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            lastRenderedCount = 0;
            quantityNodes = 0;

			CCMenuItemFont.FontSize = 64;
			CCMenuItemFont.FontName = "arial";
            CCMenuItemFont decrease = new CCMenuItemFont(" - ", onDecrease);
            decrease.Color = new CCColor3B(0, 200, 20);
            CCMenuItemFont increase = new CCMenuItemFont(" + ", onIncrease);
            increase.Color = new CCColor3B(0, 200, 20);

            CCMenu menu = new CCMenu(decrease, increase);
            menu.AlignItemsHorizontally();
            menu.Position = new CCPoint(s.Width / 2, s.Height - 65);
            AddChild(menu, 1);

            CCLabelTtf infoLabel = new CCLabelTtf("0 nodes", "Marker Felt", 30);
            infoLabel.Color = new CCColor3B(0, 200, 20);
            infoLabel.Position = new CCPoint(s.Width / 2, s.Height - 90);
            AddChild(infoLabel, 1, PerformanceSpriteTest.kTagInfoLayer);

            // add menu
            SpriteMenuLayer pMenu = new SpriteMenuLayer(true, PerformanceSpriteTest.TEST_COUNT, PerformanceSpriteTest.s_nSpriteCurCase);
            AddChild(pMenu, 1, PerformanceSpriteTest.kTagMenuLayer);

            // Sub Tests
			CCMenuItemFont.FontSize = 32;
			CCMenuItemFont.FontName = "arial";
            CCMenu pSubMenu = new CCMenu(null);
            for (int i = 1; i <= 9; ++i)
            {
                //char str[10] = {0};
                var str = string.Format("{0}", i);
                CCMenuItemFont itemFont = new CCMenuItemFont(str, testNCallback);
                itemFont.Tag = i;
                pSubMenu.AddChild(itemFont, 10);

                if (i <= 3)
                    itemFont.Color = new CCColor3B(200, 20, 20);
                else if (i <= 6)
                    itemFont.Color = new CCColor3B(0, 200, 20);
                else
                    itemFont.Color = new CCColor3B(0, 20, 200);
            }

            pSubMenu.AlignItemsHorizontally();
            pSubMenu.Position = new CCPoint(s.Width / 2, 80);
            AddChild(pSubMenu, 2);

            // add title label
            CCLabelTtf label = new CCLabelTtf(title(), "arial", 38);
            AddChild(label, 1);
            label.Position = new CCPoint(s.Width / 2, s.Height - 32);
            label.Color = new CCColor3B(255, 255, 40);

            while (quantityNodes < nNodes)
                onIncrease(this);
        }
开发者ID:h7ing,项目名称:CocosSharp,代码行数:67,代码来源:SpriteMainScene.cs

示例11: initWithSubTest

        public virtual void initWithSubTest(int asubtest, int particles)
        {
            //srandom(0);

            subtestNumber = asubtest;
            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            lastRenderedCount = 0;
            quantityParticles = particles;

			CCMenuItemFont.FontSize = 64;
			CCMenuItemFont.FontName = "arial";
            CCMenuItemFont decrease = new CCMenuItemFont(" - ", onDecrease);
            decrease.Color = new CCColor3B(0, 200, 20);
            CCMenuItemFont increase = new CCMenuItemFont(" + ", onIncrease);
            increase.Color = new CCColor3B(0, 200, 20);

            CCMenu menu = new CCMenu(decrease, increase);
            menu.AlignItemsHorizontally();
            menu.Position = new CCPoint(s.Width / 2, s.Height / 2 + 15);
            AddChild(menu, 1);

            CCLabelTtf infoLabel = new CCLabelTtf("0 nodes", "Marker Felt", 30);
            infoLabel.Color = new CCColor3B(0, 200, 20);
            infoLabel.Position = new CCPoint(s.Width / 2, s.Height - 90);
            AddChild(infoLabel, 1, PerformanceParticleTest.kTagInfoLayer);

            // particles on stage
            CCLabelAtlas labelAtlas = new CCLabelAtlas("0000", "Images/fps_Images", 12, 32, '.');
            AddChild(labelAtlas, 0, PerformanceParticleTest.kTagLabelAtlas);
            labelAtlas.Position = new CCPoint(s.Width - 66, 50);

            // Next Prev Test
            ParticleMenuLayer pMenu = new ParticleMenuLayer(true, PerformanceParticleTest.TEST_COUNT, PerformanceParticleTest.s_nParCurIdx);
            AddChild(pMenu, 1, PerformanceParticleTest.kTagMenuLayer);

            // Sub Tests
			CCMenuItemFont.FontSize = 38;
			CCMenuItemFont.FontName = "arial";
            CCMenu pSubMenu = new CCMenu(null);
            for (int i = 1; i <= 6; ++i)
            {
                //char str[10] = {0};
                string str;
                //sprintf(str, "%d ", i);
                str = string.Format("{0:G}", i);
                CCMenuItemFont itemFont = new CCMenuItemFont(str, testNCallback);
                itemFont.Tag = i;
                pSubMenu.AddChild(itemFont, 10);

                if (i <= 3)
                {
                    itemFont.Color = new CCColor3B(200, 20, 20);
                }
                else
                {
                    itemFont.Color = new CCColor3B(0, 200, 20);
                }
            }
            pSubMenu.AlignItemsHorizontally();
            pSubMenu.Position = new CCPoint(s.Width / 2, 80);
            AddChild(pSubMenu, 2);

            CCLabelTtf label = new CCLabelTtf(title(), "arial", 38);
            AddChild(label, 1);
            label.Position = new CCPoint(s.Width / 2, s.Height - 32);
            label.Color = new CCColor3B(255, 255, 40);

            updateQuantityLabel();
            createParticleSystem();

            Schedule(step);
        }
开发者ID:netonjm,项目名称:CocosSharp,代码行数:73,代码来源:ParticleMainScene.cs


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