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.AlignItemsVerticallyWithPadding(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); }
/// <summary> /// creates a menu item from a string with a target/selector /// </summary> public static CCMenuItemFont itemFromString(string value, SelectorProtocol target, SEL_MenuHandler selector) { CCMenuItemFont pRet = new CCMenuItemFont(); pRet.initFromString(value, target, selector); //pRet->autorelease(); return pRet; }
public static CCMenuItemFont itemFromString(string value) { CCMenuItemFont cCMenuItemFont = new CCMenuItemFont(); cCMenuItemFont.initFromString(value, null, null); return(cCMenuItemFont); }
public override bool Init() { if (!base.Init()) return false; var winSize = CCDirector.SharedDirector.WinSize; var tableView = new CCTableView(this, new CCSize(250, 60)); tableView.Direction = CCScrollViewDirection.Horizontal; tableView.Position = new CCPoint(20,winSize.Height/2-30); tableView.Delegate = this; this.AddChild(tableView); tableView.ReloadData(); tableView = new CCTableView(this, new CCSize(60, 280)); tableView.Direction = CCScrollViewDirection.Vertical; tableView.Position = new CCPoint(winSize.Width - 150, winSize.Height/2 - 120); tableView.Delegate = this; tableView.VerticalFillOrder = CCTableViewVerticalFillOrder.FillTopDown; this.AddChild(tableView); tableView.ReloadData(); // Back Menu var itemBack = new CCMenuItemFont("Back", toExtensionsMainLayer); itemBack.Position = new CCPoint(winSize.Width - 50, 25); var menuBack = new CCMenu(itemBack); menuBack.Position = CCPoint.Zero; AddChild(menuBack); return true; }
/// <summary> /// creates a menu item from a string without target/selector. To be used with CCMenuItemToggle /// </summary> public static CCMenuItemFont itemFromString(string value) { CCMenuItemFont pRet = new CCMenuItemFont(); pRet.initFromString(value, null, null); //pRet->autorelease(); return pRet; }
public static CCMenuItemFont itemFromString(string value, SelectorProtocol target, SEL_MenuHandler selector) { CCMenuItemFont cCMenuItemFont = new CCMenuItemFont(); cCMenuItemFont.initFromString(value, target, selector); return(cCMenuItemFont); }
public void reset() { int localtag = 0; localtag++; // TO TRIGGER THE BUG: // remove the itself from parent from an action // The menu will be removed, but the instance will be alive // and then a new node will be allocated occupying the memory. // => CRASH BOOM BANG CCNode node = GetChildByTag(localtag - 1); CCLog.Log("Menu: %p", node); RemoveChild(node, false); // [self removeChildByTag:localtag-1 cleanup:NO]; CCMenuItem item1 = new CCMenuItemFont("One", menuCallback); CCLog.Log("MenuItemFont: %p", item1); CCMenuItem item2 = new CCMenuItemFont("Two", menuCallback); CCMenu menu = new CCMenu(item1, item2); menu.AlignItemsVertically(); float x = Random.Next() * 50; float y = Random.Next() * 50; menu.Position = menu.Position + new CCPoint(x, y); AddChild(menu, 0, localtag); //[self check:self]; }
public override void OnEnter() { base.OnEnter(); var s = CCDirector.SharedDirector.WinSize; CCMenuItemFont.FontName = "arial"; CCMenuItemFont.FontSize = 24; 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); }
public override bool Init() { InitWithColor(new CCColor4B(0, 0, 255, 255)); var item0 = new CCMenuItemFont("(3) Touch to pushScene (self)", item0Clicked); var item1 = new CCMenuItemFont("(3) Touch to popScene", item1Clicked); var item2 = new CCMenuItemFont("(3) Touch to popToRootScene", item2Clicked); var item3 = new CCMenuItemFont("(3) Touch to popToSceneStackLevel(2)", item3Clicked); CCMenu menu = new CCMenu(item0, item1, item2, item3); menu.AlignItemsVertically(); AddChild(menu); CCSize s = CCDirector.SharedDirector.WinSize; CCSprite sprite = new CCSprite(s_pPathGrossini); AddChild(sprite); sprite.Position = new CCPoint(s.Width /2, 40); CCActionInterval rotate = new CCRotateBy (2, 360); CCAction repeat = new CCRepeatForever (rotate); sprite.RunAction(repeat); Schedule(testDealloc); return true; }
public IntervalLayer() { m_time0 = m_time1 = m_time2 = m_time3 = m_time4 = 0.0f; CCSize s = CCDirector.SharedDirector.WinSize; // sun CCParticleSystem sun = new CCParticleSun(); sun.Texture = CCTextureCache.SharedTextureCache.AddImage("Images/fire"); sun.Position = (new CCPoint(s.Width - 32, s.Height - 32)); sun.TotalParticles = 130; sun.Life = (0.6f); AddChild(sun); // timers m_label0 = new CCLabelBMFont("0", "fonts/bitmapFontTest4.fnt"); m_label1 = new CCLabelBMFont("0", "fonts/bitmapFontTest4.fnt"); m_label2 = new CCLabelBMFont("0", "fonts/bitmapFontTest4.fnt"); m_label3 = new CCLabelBMFont("0", "fonts/bitmapFontTest4.fnt"); m_label4 = new CCLabelBMFont("0", "fonts/bitmapFontTest4.fnt"); ScheduleUpdate(); Schedule(step1); Schedule(step2, 0); Schedule(step3, 1.0f); Schedule(step4, 2.0f); m_label0.Position = new CCPoint(s.Width * 1 / 6, s.Height / 2); m_label1.Position = new CCPoint(s.Width * 2 / 6, s.Height / 2); m_label2.Position = new CCPoint(s.Width * 3 / 6, s.Height / 2); m_label3.Position = new CCPoint(s.Width * 4 / 6, s.Height / 2); m_label4.Position = new CCPoint(s.Width * 5 / 6, s.Height / 2); AddChild(m_label0); AddChild(m_label1); AddChild(m_label2); AddChild(m_label3); AddChild(m_label4); // Sprite CCSprite sprite = new CCSprite(s_pPathGrossini); sprite.Position = new CCPoint(40, 50); CCJumpBy jump = new CCJumpBy (3, new CCPoint(s.Width - 80, 0), 50, 4); AddChild(sprite); sprite.RunAction(new CCRepeatForever ( (CCActionInterval) (CCSequence.FromActions(jump, jump.Reverse()))) ); // pause button CCMenuItem item1 = new CCMenuItemFont("Pause", onPause); CCMenu menu = new CCMenu(item1); menu.Position = new CCPoint(s.Width / 2, s.Height - 50); AddChild(menu); }
/// <summary> /// creates a menu item from a string with a target/selector /// </summary> public static CCMenuItemFont itemFromString(string value, SelectorProtocol target, SEL_MenuHandler selector) { CCMenuItemFont pRet = new CCMenuItemFont(); pRet.initFromString(value, target, selector); //pRet->autorelease(); return(pRet); }
/// <summary> /// creates a menu item from a string without target/selector. To be used with CCMenuItemToggle /// </summary> public static CCMenuItemFont itemFromString(string value) { CCMenuItemFont pRet = new CCMenuItemFont(); pRet.initFromString(value, null, null); //pRet->autorelease(); return(pRet); }
public override void OnEnter() { base.OnEnter(); CCSize s = CCDirector.SharedDirector.WinSize; CCMenuItemFont.FontName = "arial"; CCMenuItemFont.FontSize = 24; CCMenuItemFont pMainItem = new CCMenuItemFont("Back", backCallback); pMainItem.Position = new CCPoint(s.Width - 50, 25); CCMenu pMenu = new CCMenu(pMainItem, null); pMenu.Position = new CCPoint(0, 0); AddChild(pMenu); }
public virtual void initWithQuantityOfNodes(int nNodes) { //srand(time()); CCSize s = CCDirector.SharedDirector.WinSize; // Title CCLabelTTF label = new CCLabelTTF(title(), "arial", 32); 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) { CCLabelTTF l = new CCLabelTTF(strSubTitle, "arial", 16); AddChild(l, 1); l.Position = new CCPoint(s.Width / 2, s.Height - 80); } lastRenderedCount = 0; currentQuantityOfNodes = 0; quantityOfNodes = nNodes; CCMenuItemFont.FontSize = 64; 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", "arial", 30); 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(); }
public override bool Init() { if (base.Init()) { // Get the sceensize CCSize screensize = CCDirector.SharedDirector.WinSize; var pBackItem = new CCMenuItemFont("Back", toExtensionsMainLayer); pBackItem.Position = new CCPoint(screensize.Width - 50, 25); var pBackMenu = new CCMenu(pBackItem); pBackMenu.Position = CCPoint.Zero; AddChild(pBackMenu, 10); // Add the generated background var background = new CCSprite("extensions/background"); background.Position = new CCPoint(screensize.Width / 2, screensize.Height / 2); AddChild(background); // Add the ribbon var ribbon = new CCScale9SpriteFile("extensions/ribbon", new CCRect(1, 1, 48, 55)); ribbon.ContentSize = new CCSize(screensize.Width, 57); ribbon.Position = new CCPoint(screensize.Width / 2.0f, screensize.Height - ribbon.ContentSize.Height / 2.0f); AddChild(ribbon); // Add the title setSceneTitleLabel(new CCLabelTTF("Title", "arial", 12)); m_pSceneTitleLabel.Position = new CCPoint(screensize.Width / 2, screensize.Height - m_pSceneTitleLabel.ContentSize.Height / 2 - 5); AddChild(m_pSceneTitleLabel, 1); // Add the menu var item1 = new CCMenuItemImage("Images/b1", "Images/b2", previousCallback); var item2 = new CCMenuItemImage("Images/r1", "Images/r2", restartCallback); var item3 = new CCMenuItemImage("Images/f1", "Images/f2", nextCallback); var menu = new CCMenu(item1, item3, item2); menu.Position = CCPoint.Zero; item1.Position = new CCPoint(screensize.Width / 2 - 100, 37); item2.Position = new CCPoint(screensize.Width / 2, 35); item3.Position = new CCPoint(screensize.Width / 2 + 100, 37); AddChild(menu ,1); return true; } return false; }
public override void OnEnter() { base.OnEnter(); var s = CCDirector.SharedDirector.WinSize; var pMenu = new CCMenu(); pMenu.Position = CCPoint.Zero; CCMenuItemFont.FontName = "arial"; CCMenuItemFont.FontSize = 24; 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); }
public override void OnEnter() { base.OnEnter(); CCSize s = CCDirector.SharedDirector.WinSize; CCMenu pMenu = new CCMenu(null); pMenu.Position = new CCPoint(0, 0); CCMenuItemFont.FontName = "arial"; CCMenuItemFont.FontSize = 24; 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); }
public override void OnEnter() { base.OnEnter(); CCSize s = CCDirector.SharedDirector.WinSize; m_pItmeMenu = new CCMenu(null); CCMenuItemFont.FontName = "arial"; CCMenuItemFont.FontSize = 24; 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); TouchEnabled = true; }
public SceneTestLayer1() { CCMenuItemFont item1 = CCMenuItemFont.Create("(1) Test pushScene", onPushScene); CCMenuItemFont item2 = CCMenuItemFont.Create("(1) Test pushScene w/transition", onPushSceneTran); CCMenuItemFont item3 = CCMenuItemFont.Create("(1) Quit", onQuit); _PopMenuItem = CCMenuItemFont.Create("(1) Test popScene w/transition", onPopSceneTran); _TheMenu = new CCMenu(item1, item2, item3, _PopMenuItem); _TheMenu.AlignItemsVertically(); AddChild(_TheMenu); CCSize s = CCDirector.SharedDirector.WinSize; CCSprite sprite = new CCSprite(s_pPathGrossini); AddChild(sprite); sprite.Position = new CCPoint(s.Width - 40, s.Height / 2); CCActionInterval rotate = new CCRotateBy (2, 360); CCAction repeat = new CCRepeatForever (rotate); sprite.RunAction(repeat); }
public override bool Init() { bool bRet = false; do { if (!base.Init()) break; TouchEnabled = true; CCSize s = CCDirector.SharedDirector.WinSize; CCMenuItem item = new CCMenuItemFont("Rotate Device", new SEL_MenuHandler(RotateDevice)); CCMenu menu = new CCMenu(item); menu.Position = new CCPoint(s.Width / 2, s.Height / 2); AddChild(menu); bRet = true; } while (false); return bRet; }
public RenderTextureSave() { CCSize s = CCDirector.SharedDirector.WinSize; // create a render texture, this is what we are going to draw into m_pTarget = new CCRenderTexture((int) s.Width, (int) s.Height, SurfaceFormat.Color, DepthFormat.None, RenderTargetUsage.PreserveContents); // Let's clear the rendertarget here so that we start off fresh. // Some platforms do not seem to be initializing the rendertarget color so this will make sure the background shows up colored instead of // what looks like non initialized. Mostly MacOSX for now. m_pTarget.Clear(0,0,0,255); m_pTarget.Position = new CCPoint(s.Width / 2, s.Height / 2); // It's possible to modify the RenderTexture blending function by //CCBlendFunc tbf = new CCBlendFunc (OGLES.GL_ONE, OGLES.GL_ONE_MINUS_SRC_ALPHA); //m_pTarget.Sprite.BlendFunc = tbf; // note that the render texture is a CCNode, and contains a sprite of its texture for convience, // so we can just parent it to the scene like any other CCNode AddChild(m_pTarget, -1); // create a brush image to draw into the texture with m_pBrush = new CCSprite("Images/fire"); // It's possible to modify the Brushes blending function by CCBlendFunc bbf = new CCBlendFunc (OGLES.GL_ONE, OGLES.GL_ONE_MINUS_SRC_ALPHA); m_pBrush.BlendFunc = bbf; m_pBrush.Color = new CCColor3B (Color.Red); m_pBrush.Opacity = 20; TouchEnabled = true; // Save Image menu CCMenuItemFont.FontSize = 16; CCMenuItem item1 = new CCMenuItemFont("Save Image", saveImage); CCMenuItem item2 = new CCMenuItemFont("Clear", clearImage); var menu = new CCMenu(item1, item2); AddChild(menu); menu.AlignItemsVertically(); menu.Position = new CCPoint(s.Width - 80, s.Height - 30); }
public MenuLayer3() { CCMenuItemFont.FontName = "arial"; CCMenuItemFont.FontSize = 28; CCLabelBMFont label = new CCLabelBMFont("Enable AtlasItem", "fonts/bitmapFontTest3.fnt"); CCMenuItemLabel item1 = new CCMenuItemLabel(label, this.menuCallback2); CCMenuItemFont item2 = new CCMenuItemFont("--- Go Back ---", this.menuCallback); CCSprite spriteNormal = new CCSprite(s_MenuItem, new CCRect(0, 23 * 2, 115, 23)); CCSprite spriteSelected = new CCSprite(s_MenuItem, new CCRect(0, 23 * 1, 115, 23)); CCSprite spriteDisabled = new CCSprite(s_MenuItem, new CCRect(0, 23 * 0, 115, 23)); CCMenuItemSprite item3 = new CCMenuItemSprite(spriteNormal, spriteSelected, spriteDisabled, this.menuCallback3); m_disabledItem = item3; m_disabledItem.Enabled = false; CCMenu menu = new CCMenu(item1, item2, item3); menu.Position = new CCPoint(0, 0); CCSize s = CCDirector.SharedDirector.WinSize; item1.Position = new CCPoint(s.Width / 2 - 150, s.Height / 2); item2.Position = new CCPoint(s.Width / 2 - 200, s.Height / 2); item3.Position = new CCPoint(s.Width / 2, s.Height / 2 - 100); CCJumpBy jump = new CCJumpBy (3, new CCPoint(400, 0), 50, 4); item2.RunAction(new CCRepeatForever ( (CCActionInterval)(CCSequence.FromActions(jump, jump.Reverse())) ) ); CCActionInterval spin1 = new CCRotateBy (3, 360); CCActionInterval spin2 = (CCActionInterval)(spin1.Copy()); CCActionInterval spin3 = (CCActionInterval)(spin1.Copy()); item1.RunAction(new CCRepeatForever (spin1)); item2.RunAction(new CCRepeatForever (spin2)); item3.RunAction(new CCRepeatForever (spin3)); AddChild(menu); }
public override bool Init() { // always call "super" init // Apple recommends to re-assign "self" with the "super" return value if (base.Init()) { TouchEnabled = true; // ask director the the window size CCSize size = CCDirector.SharedDirector.WinSize; CCLayerColor layer; for (int i = 0; i < 5; i++) { layer = new CCLayerColor(new CCColor4B((byte)(i*20), (byte)(i*20), (byte)(i*20),255)); layer.ContentSize = new CCSize(i * 100, i * 100); layer.Position = new CCPoint(size.Width / 2, size.Height / 2); layer.AnchorPoint = new CCPoint(0.5f, 0.5f); layer.IgnoreAnchorPointForPosition = true; AddChild(layer, -1 - i); } // create and initialize a Label CCLabelTTF label = new CCLabelTTF("Hello World", "Marker Felt", 64); CCMenuItem item1 = new CCMenuItemFont("restart", restart); CCMenu menu = new CCMenu(item1); menu.AlignItemsVertically(); menu.Position = new CCPoint(size.Width / 2, 100); AddChild(menu); // position the label on the center of the screen label.Position = new CCPoint(size.Width / 2, size.Height / 2); // add the label as a child to this Layer AddChild(label); return true; } return false; }
public SceneTestLayer2() { m_timeCounter = 0; CCMenuItemFont item1 = CCMenuItemFont.Create("(2) replaceScene", onReplaceScene); CCMenuItemFont item2 = CCMenuItemFont.Create("(2) replaceScene w/transition", onReplaceSceneTran); CCMenuItemFont item3 = CCMenuItemFont.Create("(2) Go Back", onGoBack); _PopMenuItem = CCMenuItemFont.Create("(2) Test popScene w/transition", onPopSceneTran); _TheMenu = new CCMenu(item1, item2, item3, _PopMenuItem); _TheMenu.AlignItemsVertically(); AddChild(_TheMenu); CCSize s = CCDirector.SharedDirector.WinSize; CCSprite sprite = new CCSprite(s_pPathGrossini); AddChild(sprite); sprite.Position = new CCPoint(s.Width - 40, s.Height / 2); CCActionInterval rotate = new CCRotateBy (2, 360); CCAction repeat = new CCRepeatForever (rotate); sprite.RunAction(repeat); Schedule(testDealloc); }
private void alignmentChanged(object sender) { var item = (CCMenuItemFont) sender; item.Color = CCTypes.CCRed; m_pLastAlignmentItem.Color = CCTypes.CCWhite; m_pLastAlignmentItem = item; switch (item.Tag) { case LeftAlign: m_pLabelShouldRetain.SetAlignment(CCTextAlignment.CCTextAlignmentLeft); break; case CenterAlign: m_pLabelShouldRetain.SetAlignment(CCTextAlignment.CCTextAlignmentCenter); break; case RightAlign: m_pLabelShouldRetain.SetAlignment(CCTextAlignment.CCTextAlignmentRight); break; default: break; } snapArrowsToEdge(); }
public MenuLayer1() { CCMenuItemFont.FontSize = 30; CCMenuItemFont.FontName = "arial"; base.TouchEnabled = true; // Font Item CCSprite spriteNormal = new CCSprite(s_MenuItem, new CCRect(0, 23 * 2, 115, 23)); CCSprite spriteSelected = new CCSprite(s_MenuItem, new CCRect(0, 23 * 1, 115, 23)); CCSprite spriteDisabled = new CCSprite(s_MenuItem, new CCRect(0, 23 * 0, 115, 23)); CCMenuItemSprite item1 = new CCMenuItemSprite(spriteNormal, spriteSelected, spriteDisabled, this.menuCallback); // Image Item CCMenuItem item2 = new CCMenuItemImage(s_SendScore, s_PressSendScore, this.menuCallback2); // Label Item (LabelAtlas) CCLabelAtlas labelAtlas = new CCLabelAtlas("0123456789", "Images/fps_Images", 16, 24, '.'); CCMenuItemLabel item3 = new CCMenuItemLabel(labelAtlas, this.menuCallbackDisabled); item3.DisabledColor = new CCColor3B(32, 32, 64); item3.Color = new CCColor3B(200, 200, 255); // Font Item CCMenuItemFont item4 = new CCMenuItemFont("I toggle enable items", this.menuCallbackEnable); item4.FontSizeObj = 20; item4.FontNameObj = "arial"; // Label Item (CCLabelBMFont) CCLabelBMFont label = new CCLabelBMFont("configuration", "fonts/bitmapFontTest3.fnt"); CCMenuItemLabel item5 = new CCMenuItemLabel(label, this.menuCallbackConfig); // Testing issue #500 item5.Scale = 0.8f; // Events CCMenuItemFont.FontName = "arial"; CCMenuItemFont item6 = new CCMenuItemFont("Priority Test", menuCallbackPriorityTest); // Font Item CCMenuItemFont item7 = new CCMenuItemFont("Quit", this.onQuit); CCActionInterval color_action = new CCTintBy (0.5f, 0, -255, -255); CCActionInterval color_back = (CCActionInterval)color_action.Reverse(); CCFiniteTimeAction seq = CCSequence.FromActions(color_action, color_back); item7.RunAction(new CCRepeatForever ((CCActionInterval)seq)); CCMenu menu = new CCMenu(item1, item2, item3, item4, item5, item6, item7); menu.AlignItemsVertically(); // elastic effect CCSize s = CCDirector.SharedDirector.WinSize; int i = 0; CCNode child; var pArray = menu.Children; object pObject = null; if (pArray.Count > 0) { for (int j = 0; j < pArray.Count; j++) { pObject = pArray[j]; if (pObject == null) break; child = (CCNode)pObject; CCPoint dstPoint = child.Position; int offset = (int)(s.Width / 2 + 50); if (i % 2 == 0) offset = -offset; child.Position = new CCPoint(dstPoint.X + offset, dstPoint.Y); child.RunAction(new CCEaseElasticOut(new CCMoveBy (2, new CCPoint(dstPoint.X - offset, 0)), 0.35f)); i++; } } m_disabledItem = item3; m_disabledItem.Enabled = false; AddChild(menu); }
public virtual void initWithSubTest(int asubtest, int particles) { //srandom(0); subtestNumber = asubtest; CCSize s = CCDirector.SharedDirector.WinSize; lastRenderedCount = 0; quantityParticles = particles; CCMenuItemFont.FontSize = 64; 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", 16, 24, '.'); 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; 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); }
private void stringChanged(object sender) { var item = (CCMenuItemFont) sender; item.Color = CCTypes.CCRed; m_pLastAlignmentItem.Color = CCTypes.CCWhite; m_pLastAlignmentItem = item; switch (item.Tag) { case LongSentences: m_pLabelShouldRetain.Label = (LongSentencesExample); break; case LineBreaks: m_pLabelShouldRetain.Label = (LineBreaksExample); break; case Mixed: m_pLabelShouldRetain.Label = (MixedExample); break; default: break; } snapArrowsToEdge(); }
public void initWithSubTest(int asubtest, int nNodes) { //srandom(0); subtestNumber = asubtest; m_pSubTest = new SubTest(); m_pSubTest.initWithSubTest(asubtest, this); CCSize s = CCDirector.SharedDirector.WinSize; lastRenderedCount = 0; quantityNodes = 0; CCMenuItemFont.FontSize = 64; 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; 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); }
public BitmapFontMultiLineAlignment() { TouchEnabled = true; // ask director the the window size CCSize size = CCDirector.SharedDirector.WinSize; // create and initialize a Label m_pLabelShouldRetain = CCLabelBMFont.Create(LongSentencesExample, "fonts/markerFelt.fnt", size.Width / 1.5f, CCTextAlignment.CCTextAlignmentCenter); m_pArrowsBarShouldRetain = new CCSprite("Images/arrowsBar"); m_pArrowsShouldRetain = new CCSprite("Images/arrows"); CCMenuItemFont.FontSize = 20; CCMenuItemFont longSentences = CCMenuItemFont.Create("Long Flowing Sentences", stringChanged); CCMenuItemFont lineBreaks = CCMenuItemFont.Create("Short Sentences With Intentional Line Breaks", stringChanged); CCMenuItemFont mixed = CCMenuItemFont.Create("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 = CCMenuItemFont.Create("Left", alignmentChanged); CCMenuItemFont center = CCMenuItemFont.Create("Center", alignmentChanged); CCMenuItemFont right = CCMenuItemFont.Create("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); }
public MenuLayer4() { CCMenuItemFont.FontName = "arial"; CCMenuItemFont.FontSize = 18; CCMenuItemFont title1 = new CCMenuItemFont("Sound"); title1.Enabled = false; CCMenuItemFont.FontName = "arial"; CCMenuItemFont.FontSize = 34; CCMenuItemToggle item1 = new CCMenuItemToggle(this.menuCallback, new CCMenuItemFont("On"), new CCMenuItemFont("Off")); CCMenuItemFont.FontName = "arial"; CCMenuItemFont.FontSize = 18; CCMenuItemFont title2 = new CCMenuItemFont("Music"); title2.Enabled = false; CCMenuItemFont.FontName = "arial"; CCMenuItemFont.FontSize = 34; CCMenuItemToggle item2 = new CCMenuItemToggle(this.menuCallback, new CCMenuItemFont("On"), new CCMenuItemFont("Off")); CCMenuItemFont.FontName = "arial"; CCMenuItemFont.FontSize = 18; CCMenuItemFont title3 = new CCMenuItemFont("Quality"); title3.Enabled = false; CCMenuItemFont.FontName = "arial"; CCMenuItemFont.FontSize = 34; CCMenuItemToggle item3 = new CCMenuItemToggle(this.menuCallback, new CCMenuItemFont("High"), new CCMenuItemFont("Low")); CCMenuItemFont.FontName = "arial"; CCMenuItemFont.FontSize = 18; CCMenuItemFont title4 = new CCMenuItemFont("Orientation"); title4.Enabled = false; CCMenuItemFont.FontName = "arial"; CCMenuItemFont.FontSize = 34; CCMenuItemToggle item4 = new CCMenuItemToggle(this.menuCallback, new CCMenuItemFont("Off")); item4.SubItems.Add(new CCMenuItemFont("33%")); item4.SubItems.Add(new CCMenuItemFont("66%")); item4.SubItems.Add(new CCMenuItemFont("100%")); // you can change the one of the items by doing this item4.SelectedIndex = 2; CCMenuItemFont.FontName = "arial"; CCMenuItemFont.FontSize = 34; CCLabelBMFont label = new CCLabelBMFont("go back", "fonts/bitmapFontTest3.fnt"); CCMenuItemLabel back = new CCMenuItemLabel(label, this.backCallback); CCMenu menu = new CCMenu( title1, title2, item1, item2, title3, title4, item3, item4, back); // 9 items. menu.AlignItemsInColumns(2, 2, 2, 2, 1); AddChild(menu); }