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


C# CCMenu.AlignItemsHorizontallyWithPadding方法代码示例

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


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

示例1: BitmapFontMultiLineAlignment

        public BitmapFontMultiLineAlignment()
        {
            TouchEnabled = true;

            // ask director the the window size
            CCSize size = CCDirector.SharedDirector.WinSize;

            // create and initialize a Label
            m_pLabelShouldRetain = new CCLabelBMFont(LongSentencesExample, "fonts/markerFelt.fnt", size.Width / 1.5f,
                                                        CCTextAlignment.Center);

            m_pArrowsBarShouldRetain = new CCSprite("Images/arrowsBar");
            m_pArrowsShouldRetain = new CCSprite("Images/arrows");

            CCMenuItemFont.FontSize = 20;
            CCMenuItemFont longSentences = new CCMenuItemFont("Long Flowing Sentences", stringChanged);
            CCMenuItemFont lineBreaks = new CCMenuItemFont("Short Sentences With Intentional Line Breaks", stringChanged);
            CCMenuItemFont mixed = new CCMenuItemFont("Long Sentences Mixed With Intentional Line Breaks", stringChanged);
            CCMenu stringMenu = new CCMenu(longSentences, lineBreaks, mixed);
            stringMenu.AlignItemsVertically();

            longSentences.Color = CCTypes.CCRed;
            m_pLastSentenceItem = longSentences;
            longSentences.Tag = LongSentences;
            lineBreaks.Tag = LineBreaks;
            mixed.Tag = Mixed;

            CCMenuItemFont.FontSize = 30;

            CCMenuItemFont left = new CCMenuItemFont("Left", alignmentChanged);
            CCMenuItemFont center = new CCMenuItemFont("Center", alignmentChanged);
            CCMenuItemFont right = new CCMenuItemFont("Right", alignmentChanged);
            CCMenu alignmentMenu = new CCMenu(left, center, right);
            alignmentMenu.AlignItemsHorizontallyWithPadding(alignmentItemPadding);

            center.Color = CCTypes.CCRed;
            m_pLastAlignmentItem = center;
            left.Tag = (LeftAlign);
            center.Tag = (CenterAlign);
            right.Tag = (RightAlign);

            // position the label on the center of the screen
            m_pLabelShouldRetain.Position = new CCPoint(size.Width / 2, size.Height / 2);

            m_pArrowsBarShouldRetain.Visible = (false);

            float arrowsWidth = (ArrowsMax - ArrowsMin) * size.Width;
            m_pArrowsBarShouldRetain.ScaleX = (arrowsWidth / m_pArrowsBarShouldRetain.ContentSize.Width);
            m_pArrowsBarShouldRetain.Position = new CCPoint(((ArrowsMax + ArrowsMin) / 2) * size.Width, m_pLabelShouldRetain.Position.Y);

            snapArrowsToEdge();

            stringMenu.Position = new CCPoint(size.Width / 2, size.Height - menuItemPaddingCenter);
            alignmentMenu.Position = new CCPoint(size.Width / 2, menuItemPaddingCenter + 15);

            AddChild(m_pLabelShouldRetain);
            AddChild(m_pArrowsBarShouldRetain);
            AddChild(m_pArrowsShouldRetain);
            AddChild(stringMenu);
            AddChild(alignmentMenu);
        }
开发者ID:pekayatt,项目名称:cocos2d-xna,代码行数:61,代码来源:BitmapFontMultiLineAlignment.cs

示例2: TheMenu


//.........这里部分代码省略.........
			button1 = new CCMenuItemImage(lvlButtonName1, lvlButtonName1, GoToFirstLevelSection1);
			
			if (  GameData.SharedData.CanYouGoToTheFirstLevelOfThisSection(2) == false ) {
				
				button2 = new CCMenuItemImage(lvlLockedButtonName2, lvlLockedButtonName2, PlayNegativeSound);
				
			} else {
				
				button2 = new CCMenuItemImage(lvlButtonName2, lvlButtonName2, GoToFirstLevelSection2);
			}
			
			if (  GameData.SharedData.CanYouGoToTheFirstLevelOfThisSection(3) == false ) {
				
				button3 = new CCMenuItemImage(lvlLockedButtonName3, lvlLockedButtonName3, PlayNegativeSound);
				
			} else {
				
				button3 = new CCMenuItemImage(lvlButtonName3, lvlButtonName3, GoToFirstLevelSection3);
			}
			
			if (  GameData.SharedData.CanYouGoToTheFirstLevelOfThisSection(4) == false ) {
				
				button4 = new CCMenuItemImage(lvlLockedButtonName4, lvlLockedButtonName4, PlayNegativeSound);
				
			} else {
				
				button4 = new CCMenuItemImage(lvlButtonName4, lvlButtonName4, GoToFirstLevelSection4);
			}
			
			if (  GameData.SharedData.CanYouGoToTheFirstLevelOfThisSection(5) == false ) {
				
				button5 = new CCMenuItemImage(lvlLockedButtonName5, lvlLockedButtonName5, PlayNegativeSound);
				
			} else {
				
				button5 = new CCMenuItemImage(lvlButtonName5, lvlButtonName5, GoToFirstLevelSection5);
			}
			
			if (  GameData.SharedData.CanYouGoToTheFirstLevelOfThisSection(6) == false ) {
				
				button6 = new CCMenuItemImage(lvlLockedButtonName6, lvlLockedButtonName6, PlayNegativeSound);
				
			} else {
				
				button6 = new CCMenuItemImage(lvlButtonName6, lvlButtonName6, GoToFirstLevelSection6);
			}
			
			if (  GameData.SharedData.CanYouGoToTheFirstLevelOfThisSection(7) == false ) {
				
				button7 = new CCMenuItemImage(lvlLockedButtonName7, lvlLockedButtonName7, PlayNegativeSound);
				
			} else {
				
				button7 = new CCMenuItemImage(lvlButtonName7, lvlButtonName7, GoToFirstLevelSection7);
			} 
			
			if (  GameData.SharedData.CanYouGoToTheFirstLevelOfThisSection(8) == false ) {
				
				button8 = new CCMenuItemImage(lvlLockedButtonName8, lvlLockedButtonName8, PlayNegativeSound); 
				
			} else {
				
				button8 = new CCMenuItemImage(lvlButtonName8, lvlButtonName8, GoToFirstLevelSection8); 
			}
			
			if (  GameData.SharedData.CanYouGoToTheFirstLevelOfThisSection(9) == false ) {
				
				button9 = new CCMenuItemImage(lvlLockedButtonName9, lvlLockedButtonName9, PlayNegativeSound); 
				
			} else {
				
				button9 = new CCMenuItemImage(lvlButtonName9, lvlButtonName9, GoToFirstLevelSection9);  
			}
			
			if (  GameData.SharedData.CanYouGoToTheFirstLevelOfThisSection(10) == false ) {
				
				button10 = new CCMenuItemImage(lvlLockedButtonName10, lvlLockedButtonName10, PlayNegativeSound);
				
			} else {
				
				button10 = new CCMenuItemImage(lvlButtonName10, lvlButtonName10, GoToFirstLevelSection10);
			}
			
			CCMenu Menu = new CCMenu(button1, button2, button3, button4, button5);
			Menu.Position = menu1Position;
			Menu.AlignItemsHorizontallyWithPadding(10);
			AddChild(Menu, 1);

			CCMenu Menu2 = new CCMenu(button6, button7, button8, button9, button10);
			Menu2.Position = menu2Position;
			Menu2.AlignItemsHorizontallyWithPadding(10);
			AddChild(Menu2,1);


			IsSoundFXMenuItemActive = !GameData.SharedData.AreSoundFXMuted;

			IsVoiceFXMenuActive = !GameData.SharedData.AreVoiceFXMuted;

			IsAmbientFXMenuActive = !GameData.SharedData.AreAmbientFXMuted;
		}			
开发者ID:Karunp,项目名称:AngryNinjas,代码行数:101,代码来源:TheMenu.cs


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