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);
        }
Exemple #2
0
		public TheMenu ()
		{
			var screenSize = CCDirector.SharedDirector.WinSize;
			
			CCPoint menu1Position;
			CCPoint menu2Position;
			
			menuBackgroundName = "menu_background.png";  
			//will use "menu_background.png" for non-Retina Phones 
			//will use   "menu_background-hd.png"; for retina phones
			//will use "menu_background-ipad.png";
			
			//same goes for images below..
			
			lvlButtonName1 = "levelButton1.png";
			lvlLockedButtonName1 = "levelButton1_locked.png";
			
			lvlButtonName2 = "levelButton2.png";
			lvlLockedButtonName2 = "levelButton2_locked.png";
			
			lvlButtonName3 = "levelButton3.png";
			lvlLockedButtonName3 = "levelButton3_locked.png";
			
			lvlButtonName4 = "levelButton4.png";
			lvlLockedButtonName4 = "levelButton4_locked.png";
			
			lvlButtonName5 = "levelButton5.png";
			lvlLockedButtonName5 = "levelButton5_locked.png";
			
			lvlButtonName6 = "levelButton6.png";
			lvlLockedButtonName6 = "levelButton6_locked.png";
			
			lvlButtonName7 = "levelButton7.png";
			lvlLockedButtonName7 = "levelButton7_locked.png";
			
			lvlButtonName8 = "levelButton8.png";
			lvlLockedButtonName8 = "levelButton8_locked.png";
			
			lvlButtonName9 = "levelButton9.png";
			lvlLockedButtonName9 = "levelButton9_locked.png";
			
			lvlButtonName10 = "levelButton10.png";
			lvlLockedButtonName10 = "levelButton10_locked.png";
			
			voiceButtonName = "voiceFX.png";
			voiceButtonNameDim = "voiceFX_dim.png";
			
			soundButtonName = "soundFX.png";
			soundButtonNameDim = "soundFX_dim.png";
			
			ambientButtonName = "ambientFX.png";
			ambientButtonNameDim = "ambientFX_dim.png";
			
			
			if (TheLevel.SharedLevel.IS_IPAD) { //iPADs..
				
				menu1Position = new CCPoint(screenSize.Width / 2, 430 );
				menu2Position = new CCPoint(screenSize.Width / 2, 290 );
				
				SoundFXMenuLocation = new CCPoint( 240, 170 );
				VoiceFXMenuLocation = new CCPoint( 480, 170 );
				AmbientFXMenuLocation = new CCPoint(750, 170 );
				
				
				
				//if( ! CCDirector.SharedDirector.enableRetinaDisplay ) {
					
					CCLog.Log("must be iPad 1 or 2");
					
					//change nothing 
					
				//} else {
					
					CCLog.Log("retina display is on-must be iPAd 3");
					
					//change files names for iPad 3 
					
					menuBackgroundName = "menu_background-ipad.png";  //will use @"menu_background-ipad-hd.png"; 
					
					lvlButtonName1 = "levelButton1-ipad.png";
					lvlLockedButtonName1 = "levelButton1_locked-ipad.png";
					
					lvlButtonName2 = "levelButton2-ipad.png";
					lvlLockedButtonName2 = "levelButton2_locked-ipad.png";
					
					lvlButtonName3 = "levelButton3-ipad.png";
					lvlLockedButtonName3 = "levelButton3_locked-ipad.png";
					
					lvlButtonName4 = "levelButton4-ipad.png";
					lvlLockedButtonName4 = "levelButton4_locked-ipad.png";
					
					lvlButtonName5 = "levelButton5-ipad.png";
					lvlLockedButtonName5 = "levelButton5_locked-ipad.png";
					
					lvlButtonName6 = "levelButton6-ipad.png";
					lvlLockedButtonName6 = "levelButton6_locked-ipad.png";
					
					lvlButtonName7 = "levelButton7-ipad.png";
					lvlLockedButtonName7 = "levelButton7_locked-ipad.png";
					
					lvlButtonName8 = "levelButton8-ipad.png";
					lvlLockedButtonName8 = "levelButton8_locked-ipad.png";
					
					lvlButtonName9 = "levelButton9-ipad.png";
					lvlLockedButtonName9 = "levelButton9_locked-ipad.png";
					
					lvlButtonName10 = "levelButton10-ipad.png";
					lvlLockedButtonName10 = "levelButton10_locked-ipad.png";
					
					voiceButtonName = "voiceFX-ipad.png";
					voiceButtonNameDim = "voiceFX_dim-ipad.png";
					
					soundButtonName = "soundFX-ipad.png";
					soundButtonNameDim = "soundFX_dim-ipad.png";
					
					ambientButtonName = "ambientFX-ipad.png";
					ambientButtonNameDim = "ambientFX_dim-ipad.png";
				//}
				
				
			} else {  //IPHONES..
				
				
				
				menu1Position = new CCPoint(screenSize.Width / 2, 185 );
				menu2Position = new CCPoint(screenSize.Width / 2, 115 );
				
				SoundFXMenuLocation = new CCPoint( 110, 55 );
				VoiceFXMenuLocation = new CCPoint( 230, 55 );
				AmbientFXMenuLocation = new CCPoint(355, 55 );
				
			}
			
			var theBackground = new CCSprite(menuBackgroundName);
			theBackground.Position = new CCPoint(screenSize.Width / 2 , screenSize.Height / 2);
			AddChild(theBackground,0);
			
			TouchEnabled = true;
			
			CCMenuItem button1;
			CCMenuItem button2;
			CCMenuItem button3;
			CCMenuItem button4;
			CCMenuItem button5;
			CCMenuItem button6;
			CCMenuItem button7;
			CCMenuItem button8;
			CCMenuItem button9;
			CCMenuItem button10;

			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;
		}