public virtual void initWithQuantityOfNodes(int nNodes) { //srand(time()); CCSize s = Layer.VisibleBoundsWorldspace.Size; // Title var label = new CCLabel(title(), "arial", 32, CCLabelFormat.SpriteFont); AddChild(label, 1); label.Position = new CCPoint(s.Width / 2, s.Height - 32); label.Color = new CCColor3B(255, 255, 40); // Subtitle string strSubTitle = subtitle(); if (strSubTitle.Length > 0) { var l = new CCLabel(strSubTitle, "arial", 16, CCLabelFormat.SpriteFont); AddChild(l, 1); l.Position = new CCPoint(s.Width / 2, s.Height - 80); } lastRenderedCount = 0; currentQuantityOfNodes = 0; quantityOfNodes = nNodes; 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); var infoLabel = new CCLabel("0 nodes", "arial", 30, CCLabelFormat.SpriteFont); infoLabel.Color = new CCColor3B(0, 200, 20); infoLabel.Position = new CCPoint(s.Width / 2, s.Height / 2 - 15); AddChild(infoLabel, 1, PerformanceNodeChildrenTest.kTagInfoLayer); NodeChildrenMenuLayer pMenu = new NodeChildrenMenuLayer(true, PerformanceNodeChildrenTest.TEST_COUNT, PerformanceNodeChildrenTest.s_nCurCase); AddChild(pMenu); updateQuantityLabel(); updateQuantityOfNodes(); }
protected override void AddedToScene() { base.AddedToScene(); screenSize = Window.WindowSizeInPixels; CCPoint menu1Position; CCPoint menu2Position; menuBackgroundName = "menu_background"; //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"; lvlLockedButtonName1 = "levelButton1_locked"; lvlButtonName2 = "levelButton2"; lvlLockedButtonName2 = "levelButton2_locked"; lvlButtonName3 = "levelButton3"; lvlLockedButtonName3 = "levelButton3_locked"; lvlButtonName4 = "levelButton4"; lvlLockedButtonName4 = "levelButton4_locked"; lvlButtonName5 = "levelButton5"; lvlLockedButtonName5 = "levelButton5_locked"; lvlButtonName6 = "levelButton6"; lvlLockedButtonName6 = "levelButton6_locked"; lvlButtonName7 = "levelButton7"; lvlLockedButtonName7 = "levelButton7_locked"; lvlButtonName8 = "levelButton8"; lvlLockedButtonName8 = "levelButton8_locked"; lvlButtonName9 = "levelButton9"; lvlLockedButtonName9 = "levelButton9_locked"; lvlButtonName10 = "levelButton10"; lvlLockedButtonName10 = "levelButton10_locked"; voiceButtonName = "voiceFX"; voiceButtonNameDim = "voiceFX_dim"; soundButtonName = "soundFX"; soundButtonNameDim = "soundFX_dim"; ambientButtonName = "ambientFX"; ambientButtonNameDim = "ambientFX_dim"; 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"; //will use @"menu_background-ipad-hd"; lvlButtonName1 = "levelButton1-ipad"; lvlLockedButtonName1 = "levelButton1_locked-ipad"; lvlButtonName2 = "levelButton2-ipad"; lvlLockedButtonName2 = "levelButton2_locked-ipad"; lvlButtonName3 = "levelButton3-ipad"; lvlLockedButtonName3 = "levelButton3_locked-ipad"; lvlButtonName4 = "levelButton4-ipad"; lvlLockedButtonName4 = "levelButton4_locked-ipad"; lvlButtonName5 = "levelButton5-ipad"; lvlLockedButtonName5 = "levelButton5_locked-ipad"; lvlButtonName6 = "levelButton6-ipad"; lvlLockedButtonName6 = "levelButton6_locked-ipad"; lvlButtonName7 = "levelButton7-ipad"; lvlLockedButtonName7 = "levelButton7_locked-ipad"; lvlButtonName8 = "levelButton8-ipad"; lvlLockedButtonName8 = "levelButton8_locked-ipad"; lvlButtonName9 = "levelButton9-ipad"; lvlLockedButtonName9 = "levelButton9_locked-ipad"; lvlButtonName10 = "levelButton10-ipad"; lvlLockedButtonName10 = "levelButton10_locked-ipad"; voiceButtonName = "voiceFX-ipad"; voiceButtonNameDim = "voiceFX_dim-ipad"; soundButtonName = "soundFX-ipad"; soundButtonNameDim = "soundFX_dim-ipad"; ambientButtonName = "ambientFX-ipad"; ambientButtonNameDim = "ambientFX_dim-ipad"; //} } 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.AlignItemsHorizontally(10); AddChild(Menu, 1); CCMenu Menu2 = new CCMenu(button6, button7, button8, button9, button10); Menu2.Position = menu2Position; Menu2.AlignItemsHorizontally(10); AddChild(Menu2, 1); IsSoundFXMenuItemActive = !GameData.SharedData.AreSoundFXMuted; IsVoiceFXMenuActive = !GameData.SharedData.AreVoiceFXMuted; IsAmbientFXMenuActive = !GameData.SharedData.AreAmbientFXMuted; }
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); }
protected override void AddedToScene() { base.AddedToScene(); // ask director the the window size var size = VisibleBoundsWorldspace.Size; // create and initialize a Label label = new CCLabel(LongSentencesExample, "fonts/markerFelt.fnt", new CCSize(size.Width / 3f, 0), CCTextAlignment.Center); //label.LineBreakWithoutSpace = true; arrowsBar = new CCSprite("Images/arrowsBar"); arrows = new CCSprite("Images/arrows"); CCMenuItemFont.FontSize = 20; CCMenuItemFont.FontName = "arial"; var longSentences = new CCMenuItemFont("Long Flowing Sentences", stringChanged); var lineBreaks = new CCMenuItemFont("Short Sentences With Intentional Line Breaks", stringChanged); var mixed = new CCMenuItemFont("Long Sentences Mixed With Intentional Line Breaks", stringChanged); var stringMenu = new CCMenu(longSentences, lineBreaks, mixed); stringMenu.AlignItemsVertically(); longSentences.Color = CCColor3B.Red; lastSentenceItem = longSentences; longSentences.Tag = LongSentences; lineBreaks.Tag = LineBreaks; mixed.Tag = Mixed; CCMenuItemFont.FontSize = 30; var left = new CCMenuItemFont("Left", alignmentChanged); var center = new CCMenuItemFont("Center", alignmentChanged); var right = new CCMenuItemFont("Right", alignmentChanged); var alignmentMenu = new CCMenu(left, center, right); alignmentMenu.AlignItemsHorizontally(alignmentItemPadding); center.Color = CCColor3B.Red; lastAlignmentItem = center; left.Tag = LeftAlign; center.Tag = CenterAlign; right.Tag = RightAlign; // position the label on the center of the screen label.Position = size.Center; arrowsBar.Visible = false; float arrowsWidth = (ArrowsMax - ArrowsMin) * size.Width; arrowsBar.ScaleX = (arrowsWidth / arrowsBar.ContentSize.Width); arrowsBar.Position = new CCPoint(((ArrowsMax + ArrowsMin) / 2) * size.Width, label.Position.Y); snapArrowsToEdge(); stringMenu.Position = new CCPoint(size.Width / 2, size.Height - menuItemPaddingCenter); alignmentMenu.Position = new CCPoint(size.Width / 2, menuItemPaddingCenter + 15); AddChild(label); AddChild(arrowsBar); AddChild(arrows); AddChild(stringMenu); AddChild(alignmentMenu); }
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); }