本文整理汇总了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);
}
示例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;
}