public void reset() { Random random = new Random(); 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); Debug.WriteLine("Menu: %p", node); removeChild(node, false); // [self removeChildByTag:localtag-1 cleanup:NO]; CCMenuItem item1 = CCMenuItemFont.itemFromString("One", this, menuCallback); Debug.WriteLine("MenuItemFont: %p", item1); CCMenuItem item2 = CCMenuItemFont.itemFromString("Two", this, menuCallback); CCMenu menu = CCMenu.menuWithItems(item1, item2); menu.alignItemsVertically(); float x = random.Next() * 50; float y = random.Next() * 50; menu.position = CCPointExtension.ccpAdd(menu.position, new CCPoint(x, y)); addChild(menu, 0, localtag); //[self check:self]; }
public override void onEnter() { base.onEnter(); CCSize s = CCDirector.sharedDirector().getWinSize(); CCMenuItemFont.FontName = "Arial"; CCMenuItemFont.FontSize = 24; CCMenuItemFont pMainItem = CCMenuItemFont.itemFromString("Back", this, toMainLayer); pMainItem.position = new CCPoint(s.width - 50, 25); CCMenu pMenu = CCMenu.menuWithItems(pMainItem); pMenu.position = new CCPoint(0, 0); if (m_bControlMenuVisible) { CCMenuItemImage item1 = CCMenuItemImage.itemFromNormalImage("Images/b1", "Images/b2", this, backCallback); CCMenuItemImage item2 = CCMenuItemImage.itemFromNormalImage("Images/r1", "Images/r2", this, restartCallback); CCMenuItemImage item3 = CCMenuItemImage.itemFromNormalImage("Images/f1", "Images/f2", this, 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 SceneTestLayer2() { m_timeCounter = 0; CCMenuItemFont item1 = CCMenuItemFont.itemFromString("replaceScene", this, onReplaceScene); CCMenuItemFont item2 = CCMenuItemFont.itemFromString("replaceScene w/transition", this, onReplaceSceneTran); CCMenuItemFont item3 = CCMenuItemFont.itemFromString("Go Back", this, onGoBack); CCMenu menu = CCMenu.menuWithItems(item1, item2, item3); menu.alignItemsVertically(); addChild(menu); CCSize s = CCDirector.sharedDirector().getWinSize(); CCSprite sprite = CCSprite.spriteWithFile(s_pPathGrossini); addChild(sprite); sprite.position = new CCPoint(s.width - 40, s.height / 2); CCActionInterval rotate = CCRotateBy.actionWithDuration(2, 360); CCAction repeat = CCRepeatForever.actionWithAction(rotate); sprite.runAction(repeat); schedule(testDealloc); }
public RenderTextureSave() { CCSize s = CCDirector.sharedDirector().getWinSize(); // create a render texture, this is what we are going to draw into m_pTarget = CCRenderTexture.renderTextureWithWidthAndHeight((int)s.width, (int)s.height); //m_pTarget->retain(); m_pTarget.position = new CCPoint(s.width / 2, s.height / 2); // 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 this.addChild(m_pTarget, -1); // create a brush image to draw into the texture with m_pBrush = CCSprite.spriteWithFile("Images/fire.png"); //m_pBrush->retain(); m_pBrush.Opacity = 20; //this->setIsTouchEnabled(true); isTouchEnabled = true; // Save Image menu CCMenuItemFont.FontSize = 16; CCMenuItem item1 = CCMenuItemFont.itemFromString("Save Image", this, saveImage); CCMenuItem item2 = CCMenuItemFont.itemFromString("Clear", this, clearImage); CCMenu menu = CCMenu.menuWithItems(item1, item2); this.addChild(menu); menu.alignItemsVertically(); menu.position = new CCPoint(s.width - 80, s.height - 30); }
public ParticleDemo() { initWithColor(ccTypes.ccc4(127, 127, 127, 255)); m_emitter = null; isTouchEnabled = true; CCSize s = CCDirector.sharedDirector().getWinSize(); CCLabelTTF label = CCLabelTTF.labelWithString(title(), "Arial", 28); addChild(label, 100, 1000); label.position = new CCPoint(s.width / 2, s.height - 50); CCLabelTTF tapScreen = CCLabelTTF.labelWithString("(Tap the Screen)", "Arial", 20); tapScreen.position = new CCPoint(s.width / 2, s.height - 80); addChild(tapScreen, 100); CCMenuItemImage item1 = CCMenuItemImage.itemFromNormalImage(TestResource.s_pPathB1, TestResource.s_pPathB2, this, new SEL_MenuHandler(backCallback)); CCMenuItemImage item2 = CCMenuItemImage.itemFromNormalImage(TestResource.s_pPathR1, TestResource.s_pPathR2, this, new SEL_MenuHandler(restartCallback)); CCMenuItemImage item3 = CCMenuItemImage.itemFromNormalImage(TestResource.s_pPathF1, TestResource.s_pPathF2, this, new SEL_MenuHandler(nextCallback)); CCMenuItemToggle item4 = CCMenuItemToggle.itemWithTarget(this, new SEL_MenuHandler(toggleCallback), CCMenuItemFont.itemFromString("Free Movement"), CCMenuItemFont.itemFromString("Relative Movement"), CCMenuItemFont.itemFromString("Grouped Movement")); CCMenu menu = CCMenu.menuWithItems(item1, item2, item3, item4); menu.position = new CCPoint(0, 0); 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); item4.position = new CCPoint(0, 100); item4.anchorPoint = new CCPoint(0, 0); addChild(menu, 100); CCLabelAtlas labelAtlas = CCLabelAtlas.labelWithString("0000", "fonts/fnt/images/fps_images", 16, 24, '.'); addChild(labelAtlas, 100, ParticleTestScene.kTagLabelAtlas); labelAtlas.position = new CCPoint(s.width - 66, 50); // moving background m_background = CCSprite.spriteWithFile(TestResource.s_back3); addChild(m_background, 5); m_background.position = new CCPoint(s.width / 2 - 120, s.height - 240); CCActionInterval move = CCMoveBy.actionWithDuration(4, new CCPoint(300, 0)); CCFiniteTimeAction move_back = move.reverse(); CCFiniteTimeAction seq = CCSequence.actions(move, move_back); m_background.runAction(CCRepeatForever.actionWithAction((CCActionInterval)seq)); schedule(new SEL_SCHEDULE(step)); }
public IntervalLayer() { m_time0 = m_time1 = m_time2 = m_time3 = m_time4 = 0.0f; CCSize s = CCDirector.sharedDirector().getWinSize(); // sun //CCParticleSystem sun = CCParticleSun.node(); //sun.Texture = CCTextureCache.sharedTextureCache().addImage("Images/fire"); //sun.position = (new CCPoint(s.width - 32, s.height - 32)); ////sun.setTotalParticles(130); //sun.Life = (0.6f); //this.addChild(sun); // timers m_label0 = CCLabelBMFont.labelWithString("0", "fonts/fnt/bitmapFontTest4"); m_label1 = CCLabelBMFont.labelWithString("0", "fonts/fnt/bitmapFontTest4"); m_label2 = CCLabelBMFont.labelWithString("0", "fonts/fnt/bitmapFontTest4"); m_label3 = CCLabelBMFont.labelWithString("0", "fonts/fnt/bitmapFontTest4"); m_label4 = CCLabelBMFont.labelWithString("0", "fonts/fnt/bitmapFontTest4"); base.scheduleUpdate(); schedule(step1); schedule(step2, 0); schedule(step3, 1.0f); schedule(step4, 2.0f); 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 = CCSprite.spriteWithFile(s_pPathGrossini); sprite.position = new CCPoint(40, 50); CCJumpBy jump = CCJumpBy.actionWithDuration(3, new CCPoint(s.width - 80, 0), 50, 4); addChild(sprite); sprite.runAction(CCRepeatForever.actionWithAction( (CCActionInterval)(CCSequence.actions(jump, jump.reverse())) ) ); // pause button CCMenuItem item1 = CCMenuItemFont.itemFromString("Pause", this, onPause); CCMenu menu = CCMenu.menuWithItems(item1); menu.position = new CCPoint(s.width / 2, s.height - 50); addChild(menu); }
public override bool init() { // always call "super" init // Apple recommends to re-assign "self" with the "super" return value if (base.init()) { isTouchEnabled = true; // ask director the the window size CCSize size = CCDirector.sharedDirector().getWinSize(); CCLayerColor layer; CCUserDefault.sharedUserDefault().setBoolForKey("bool", true); for (int i = 0; i < 5; i++) { ccColor4B c = new ccColor4B((byte)(i * 20), (byte)(i * 20), (byte)(i * 20), 255); CCUserDefault.sharedUserDefault().setStringForKey("i" + i, c.ToString()); } CCUserDefault.sharedUserDefault().flush(); bool testValue = CCUserDefault.sharedUserDefault().getBoolForKey("bool", false); if (!testValue) { CCLog.Log("CCUserDefault: Test failed b/c the 'bool' value was not true when it was expected."); } for (int i = 0; i < 5; i++) { string cstr = CCUserDefault.sharedUserDefault().getStringForKey("i" + i, null); if (cstr == null) { CCLog.Log("CCUserDefault: The color for iteration #" + i + " is null."); continue; } ccColor4B c = new ccColor4B((byte)(i * 20), (byte)(i * 20), (byte)(i * 20), 255); layer = CCLayerColor.layerWithColor(c); 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.isRelativeAnchorPoint = true; addChild(layer, -1 - i); } // create and initialize a Label CCLabelTTF label = CCLabelTTF.labelWithString("ccUserDefault Test", "Arial", 14); CCMenuItem item1 = CCMenuItemFont.itemFromString("restart", this, restart); CCMenu menu = CCMenu.menuWithItems(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 virtual void initWithQuantityOfNodes(int nNodes) { //srand(time()); CCSize s = CCDirector.sharedDirector().getWinSize(); // Title CCLabelTTF label = CCLabelTTF.labelWithString(title(), "Arial", 40); 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 = CCLabelTTF.labelWithString(strSubTitle, "Thonburi", 16); addChild(l, 1); l.position = new CCPoint(s.width / 2, s.height - 80); } lastRenderedCount = 0; currentQuantityOfNodes = 0; quantityOfNodes = nNodes; CCMenuItemFont.FontSize = 65; CCMenuItemFont decrease = CCMenuItemFont.itemFromString(" - ", this, onDecrease); decrease.Color = new ccColor3B(0, 200, 20); CCMenuItemFont increase = CCMenuItemFont.itemFromString(" + ", this, onIncrease); increase.Color = new ccColor3B(0, 200, 20); CCMenu menu = CCMenu.menuWithItems(decrease, increase); menu.alignItemsHorizontally(); menu.position = new CCPoint(s.width / 2, s.height / 2 + 15); addChild(menu, 1); CCLabelTTF infoLabel = CCLabelTTF.labelWithString("0 nodes", "Marker Felt", 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 void onEnter() { base.onEnter(); CCSize s = CCDirector.sharedDirector().getWinSize(); CCMenuItemFont.FontName = "Arial"; CCMenuItemFont.FontSize = 24; CCMenuItemFont pMainItem = CCMenuItemFont.itemFromString("Back", this, backCallback); pMainItem.position = new CCPoint(s.width - 50, 25); CCMenu pMenu = CCMenu.menuWithItems(pMainItem, null); pMenu.position = new CCPoint(0, 0); addChild(pMenu); }
public MenuLayer3() { CCMenuItemFont.FontName = "Arial"; CCMenuItemFont.FontSize = 28; CCLabelBMFont label = CCLabelBMFont.labelWithString("Enable AtlasItem", "fonts/fnt/bitmapFontTest3"); CCMenuItemLabel item1 = CCMenuItemLabel.itemWithLabel(label, this, this.menuCallback2); CCMenuItemFont item2 = CCMenuItemFont.itemFromString("--- Go Back ---", this, this.menuCallback); m_item2 = item2; m_item1 = item1; CCSprite spriteNormal = CCSprite.spriteWithFile(s_MenuItem, new CCRect(0, 23 * 2, 115, 23)); CCSprite spriteSelected = CCSprite.spriteWithFile(s_MenuItem, new CCRect(0, 23 * 1, 115, 23)); CCSprite spriteDisabled = CCSprite.spriteWithFile(s_MenuItem, new CCRect(0, 23 * 0, 115, 23)); CCMenuItemSprite item3 = CCMenuItemSprite.itemFromNormalSprite(spriteNormal, spriteSelected, spriteDisabled, this, this.menuCallback3); m_disabledItem = item3; m_disabledItem.Enabled = false; m_item3 = item3; CCMenu menu = CCMenu.menuWithItems(item1, item2, item3); menu.position = new CCPoint(0, 0); addChild(menu); CCSize s = CCDirector.sharedDirector().getWinSize(); m_item1.position = new CCPoint(s.width / 2 - 150, s.height / 2); m_item2.position = new CCPoint(s.width / 2 - 200, s.height / 2); m_item3.position = new CCPoint(s.width / 2, s.height / 2 - 100); CCJumpBy jump = CCJumpBy.actionWithDuration(3, new CCPoint(400, 0), 50, 4); CCActionInterval spin1 = CCRotateBy.actionWithDuration(3, 360); CCActionInterval spin2 = (CCActionInterval)(spin1.copy()); CCActionInterval spin3 = (CCActionInterval)(spin1.copy()); m_item1.runAction(CCRepeatForever.actionWithAction(spin1)); m_item2.runAction(CCRepeatForever.actionWithAction( (CCActionInterval)(CCSequence.actions(jump, jump.reverse())) ) ); m_item2.runAction(CCRepeatForever.actionWithAction(spin2)); // Augments the jump m_item3.runAction(CCRepeatForever.actionWithAction(spin3)); }
public override void onEnter() { base.onEnter(); CCSize s = CCDirector.sharedDirector().getWinSize(); CCMenu pMenu = CCMenu.menuWithItems(null); pMenu.position = new CCPoint(0, 0); CCMenuItemFont.FontName = "Arial"; CCMenuItemFont.FontSize = 24; for (int i = 0; i < PerformanceTestScene.MAX_COUNT; ++i) { CCMenuItemFont pItem = CCMenuItemFont.itemFromString(PerformanceTestScene.testsName[i], this, 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().getWinSize(); m_pItmeMenu = CCMenu.menuWithItems(null); CCMenuItemFont.FontName = "Arial"; CCMenuItemFont.FontSize = 24; for (int i = 0; i < BugsTestScene.MAX_COUNT; ++i) { CCMenuItemFont pItem = CCMenuItemFont.itemFromString(BugsTestScene.testsName[i], this, 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); isTouchEnabled = true; }
public override bool init() { // always call "super" init // Apple recommends to re-assign "self" with the "super" return value if (base.init()) { isTouchEnabled = true; // ask director the the window size CCSize size = CCDirector.sharedDirector().getWinSize(); CCLayerColor layer; for (int i = 0; i < 5; i++) { layer = CCLayerColor.layerWithColor(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.isRelativeAnchorPoint = true; addChild(layer, -1 - i); } // create and initialize a Label CCLabelTTF label = CCLabelTTF.labelWithString("Hello World", "Marker Felt", 64); CCMenuItem item1 = CCMenuItemFont.itemFromString("restart", this, restart); CCMenu menu = CCMenu.menuWithItems(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 override bool init() { bool bRet = false; do { if (!base.init()) { break; } isTouchEnabled = true; CCSize s = CCDirector.sharedDirector().getWinSize(); CCMenuItem item = CCMenuItemFont.itemFromString("Rotate Device", this, new SEL_MenuHandler(rotateDevice)); CCMenu menu = CCMenu.menuWithItems(item); menu.position = new CCPoint(s.width / 2, s.height / 2); addChild(menu); bRet = true; } while (false); return(bRet); }
public MenuLayer4() { CCMenuItemFont.FontName = "Arial"; CCMenuItemFont.FontSize = 18; CCMenuItemFont title1 = CCMenuItemFont.itemFromString("Sound"); title1.Enabled = false; CCMenuItemFont.FontName = "Arial"; CCMenuItemFont.FontSize = 34; CCMenuItemToggle item1 = CCMenuItemToggle.itemWithTarget(this, this.menuCallback, CCMenuItemFont.itemFromString("On"), CCMenuItemFont.itemFromString("Off")); CCMenuItemFont.FontName = "Arial"; CCMenuItemFont.FontSize = 18; CCMenuItemFont title2 = CCMenuItemFont.itemFromString("Music"); title2.Enabled = false; CCMenuItemFont.FontName = "Arial"; CCMenuItemFont.FontSize = 34; CCMenuItemToggle item2 = CCMenuItemToggle.itemWithTarget(this, this.menuCallback, CCMenuItemFont.itemFromString("On"), CCMenuItemFont.itemFromString("Off")); CCMenuItemFont.FontName = "Arial"; CCMenuItemFont.FontSize = 18; CCMenuItemFont title3 = CCMenuItemFont.itemFromString("Quality"); title3.Enabled = false; CCMenuItemFont.FontName = "Arial"; CCMenuItemFont.FontSize = 34; CCMenuItemToggle item3 = CCMenuItemToggle.itemWithTarget(this, this.menuCallback, CCMenuItemFont.itemFromString("High"), CCMenuItemFont.itemFromString("Low")); CCMenuItemFont.FontName = "Arial"; CCMenuItemFont.FontSize = 18; CCMenuItemFont title4 = CCMenuItemFont.itemFromString("Orientation"); title4.Enabled = false; CCMenuItemFont.FontName = "Arial"; CCMenuItemFont.FontSize = 34; CCMenuItemToggle item4 = CCMenuItemToggle.itemWithTarget(this, this.menuCallback, CCMenuItemFont.itemFromString("Off")); item4.SubItems.Add(CCMenuItemFont.itemFromString("33%")); item4.SubItems.Add(CCMenuItemFont.itemFromString("66%")); item4.SubItems.Add(CCMenuItemFont.itemFromString("100%")); // you can change the one of the items by doing this item4.SelectedIndex = 2; CCMenuItemFont.FontName = "Arial"; CCMenuItemFont.FontSize = 34; CCLabelBMFont label = CCLabelBMFont.labelWithString("go back", "fonts/fnt/bitmapFontTest3"); CCMenuItemLabel back = CCMenuItemLabel.itemWithLabel(label, this, this.backCallback); CCMenu menu = CCMenu.menuWithItems( title1, title2, item1, item2, title3, title4, item3, item4, back); // 9 items. menu.alignItemsInColumns(2, 2, 2, 2, 1); addChild(menu); }
public void initWithSubTest(int asubtest, int nNodes) { //srandom(0); subtestNumber = asubtest; m_pSubTest = new SubTest(); m_pSubTest.initWithSubTest(asubtest, this); CCSize s = CCDirector.sharedDirector().getWinSize(); lastRenderedCount = 0; quantityNodes = 0; CCMenuItemFont.FontSize = 65; CCMenuItemFont decrease = CCMenuItemFont.itemFromString(" - ", this, onDecrease); decrease.Color = new ccColor3B(0, 200, 20); CCMenuItemFont increase = CCMenuItemFont.itemFromString(" + ", this, onIncrease); increase.Color = new ccColor3B(0, 200, 20); CCMenu menu = CCMenu.menuWithItems(decrease, increase); menu.alignItemsHorizontally(); menu.position = new CCPoint(s.width / 2, s.height - 65); addChild(menu, 1); CCLabelTTF infoLabel = CCLabelTTF.labelWithString("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 = CCMenu.menuWithItems(null); for (int i = 1; i <= 9; ++i) { //char str[10] = {0}; string str; //sprintf(str, "%d ", i); str = string.Format("{0:D}", i); CCMenuItemFont itemFont = CCMenuItemFont.itemFromString(str, this, 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 = CCLabelTTF.labelWithString(title(), "Arial", 40); 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 virtual void initWithSubTest(int asubtest, int particles) { //srandom(0); subtestNumber = asubtest; CCSize s = CCDirector.sharedDirector().getWinSize(); lastRenderedCount = 0; quantityParticles = particles; CCMenuItemFont.FontSize = 65; CCMenuItemFont decrease = CCMenuItemFont.itemFromString(" - ", this, onDecrease); decrease.Color = new ccColor3B(0, 200, 20); CCMenuItemFont increase = CCMenuItemFont.itemFromString(" + ", this, onIncrease); increase.Color = new ccColor3B(0, 200, 20); CCMenu menu = CCMenu.menuWithItems(decrease, increase); menu.alignItemsHorizontally(); menu.position = new CCPoint(s.width / 2, s.height / 2 + 15); addChild(menu, 1); CCLabelTTF infoLabel = CCLabelTTF.labelWithString("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 = CCLabelAtlas.labelWithString("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 = 40; CCMenu pSubMenu = CCMenu.menuWithItems(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 = CCMenuItemFont.itemFromString(str, this, 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 = CCLabelTTF.labelWithString(title(), "Arial", 40); addChild(label, 1); label.position = new CCPoint(s.width / 2, s.height - 32); label.Color = new ccColor3B(255, 255, 40); updateQuantityLabel(); createParticleSystem(); schedule(step); }
public MenuLayer1() { CCMenuItemFont.FontSize = 30; CCMenuItemFont.FontName = "Arial"; base.isTouchEnabled = true; // Font Item CCSprite spriteNormal = CCSprite.spriteWithFile(s_MenuItem, new CCRect(0, 23 * 2, 115, 23)); CCSprite spriteSelected = CCSprite.spriteWithFile(s_MenuItem, new CCRect(0, 23 * 1, 115, 23)); CCSprite spriteDisabled = CCSprite.spriteWithFile(s_MenuItem, new CCRect(0, 23 * 0, 115, 23)); CCMenuItemSprite item1 = CCMenuItemSprite.itemFromNormalSprite(spriteNormal, spriteSelected, spriteDisabled, this, this.menuCallback); // Image Item CCMenuItem item2 = CCMenuItemImage.itemFromNormalImage(s_SendScore, s_PressSendScore, this, this.menuCallback2); // Label Item (LabelAtlas) CCLabelAtlas labelAtlas = CCLabelAtlas.labelWithString("0123456789", "Images/fps_images", 16, 24, '.'); CCMenuItemLabel item3 = CCMenuItemLabel.itemWithLabel(labelAtlas, this, this.menuCallbackDisabled); item3.DisabledColor = new ccColor3B(32, 32, 64); item3.Color = new ccColor3B(200, 200, 255); // Font Item CCMenuItemFont item4 = CCMenuItemFont.itemFromString("I toggle enable items", this, this.menuCallbackEnable); item4.FontSizeObj = 20; item4.FontNameObj = "Arial"; // Label Item (CCLabelBMFont) CCLabelBMFont label = CCLabelBMFont.labelWithString("configuration", "fonts/fnt/bitmapFontTest3"); CCMenuItemLabel item5 = CCMenuItemLabel.itemWithLabel(label, this, this.menuCallbackConfig); // Testing issue #500 item5.scale = 0.8f; // Font Item CCMenuItemFont item6 = CCMenuItemFont.itemFromString("Quit", this, this.onQuit); CCActionInterval color_action = CCTintBy.actionWithDuration(0.5f, 0, -255, -255); CCActionInterval color_back = (CCActionInterval)color_action.reverse(); CCFiniteTimeAction seq = CCSequence.actions(color_action, color_back); item6.runAction(CCRepeatForever.actionWithAction((CCActionInterval)seq)); CCMenu menu = CCMenu.menuWithItems(item1, item2, item3, item4, item5, item6); menu.alignItemsVertically(); // elastic effect CCSize s = CCDirector.sharedDirector().getWinSize(); int i = 0; CCNode child; List <CCNode> pArray = menu.children; CCObject 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(CCEaseElasticOut.actionWithAction(CCMoveBy.actionWithDuration(2, new CCPoint(dstPoint.x - offset, 0)), 0.35f)); i++; } } m_disabledItem = item3; m_disabledItem.Enabled = false; addChild(menu); }