public override void onEnter() { base.onEnter(); CCSize s = CCDirector.sharedDirector().getWinSize(); CCLabelTTF label = CCLabelTTF.labelWithString(title(), "Arial", 32); addChild(label, 1); label.position = (new CCPoint(s.width / 2, s.height - 50)); string subtitle_ = subtitle(); if (subtitle_.Length > 0) { CCLabelTTF l = CCLabelTTF.labelWithString(subtitle_, "Arial", 16); addChild(l, 1); l.position = (new CCPoint(s.width / 2, s.height - 80)); } CCMenuItemImage item1 = CCMenuItemImage.itemFromNormalImage(s_pPathB1, s_pPathB2, this, (backCallback)); CCMenuItemImage item2 = CCMenuItemImage.itemFromNormalImage(s_pPathR1, s_pPathR2, this, (restartCallback)); CCMenuItemImage item3 = CCMenuItemImage.itemFromNormalImage(s_pPathF1, s_pPathF2, this, (nextCallback)); CCMenu menu = CCMenu.menuWithItems(item1, item2, item3); 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); addChild(menu, 1); }
public override void onEnter() { base.onEnter(); float x, y; CCSize size = CCDirector.sharedDirector().getWinSize(); x = size.width; y = size.height; CCSprite bg = CCSprite.spriteWithFile("Images/background3"); addChild(bg, 0, EffectAdvanceScene.kTagBackground); bg.position = new CCPoint(x / 2, y / 2); grossini = CCSprite.spriteWithFile("Images/grossinis_sister2"); bg.addChild(grossini, 1, EffectAdvanceScene.kTagSprite1); grossini.position = new CCPoint(x / 3.0f, 200); CCActionInterval sc = CCScaleBy.actionWithDuration(2, 5); CCFiniteTimeAction sc_back = sc.reverse(); grossini.runAction(CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(sc, sc_back)))); tamara = CCSprite.spriteWithFile("Images/grossinis_sister1"); bg.addChild(tamara, 1, EffectAdvanceScene.kTagSprite2); tamara.position = new CCPoint(2 * x / 3.0f, 200); CCActionInterval sc2 = CCScaleBy.actionWithDuration(2, 5); CCFiniteTimeAction sc2_back = sc2.reverse(); tamara.runAction(CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(sc2, sc2_back)))); CCLabelTTF label = CCLabelTTF.labelWithString(title(), "Arial", 28); label.position = new CCPoint(x / 2, y - 80); addChild(label); label.tag = EffectAdvanceScene.kTagLabel; string strSubtitle = subtitle(); if (strSubtitle != null) { CCLabelTTF l = CCLabelTTF.labelWithString(strSubtitle, "Arial", 16); addChild(l, 101); l.position = new CCPoint(size.width / 2, size.height - 80); } 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); CCMenu menu = CCMenu.menuWithItems(item1, item2, item3); menu.position = new CCPoint(0, 0); item1.position = new CCPoint(size.width / 2 - 100, 30); item2.position = new CCPoint(size.width / 2, 30); item3.position = new CCPoint(size.width / 2 + 100, 30); addChild(menu, 1); }
public override void onEnter() { base.onEnter(); CCSize s = CCDirector.sharedDirector().getWinSize(); CCLabelTTF label = CCLabelTTF.labelWithString(title(), "Arial", 28); addChild(label, 1); label.position = new CCPoint(s.width / 2, s.height - 50); string strSubtitle = subtitle(); if (!string.IsNullOrEmpty(strSubtitle)) { CCLabelTTF l = CCLabelTTF.labelWithString(strSubtitle, "Arial", 16); //CCLabelTTF l = CCLabelTTF.labelWithString(strSubtitle, "Thonburi", 16); addChild(l, 1); l.position = new CCPoint(s.width / 2, s.height - 80); } 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); CCMenu menu = CCMenu.menuWithItems(item1, item2, item3); menu.position = new CCPoint(); 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); addChild(menu, 1); }
public NodeToWorld() { // // This code tests that nodeToParent works OK: // - It tests different anchor Points // - It tests different children anchor points CCSprite back = CCSprite.spriteWithFile(TestResource.s_back3); addChild(back, -10); back.anchorPoint = (new CCPoint(0, 0)); CCSize backSize = back.contentSize; CCMenuItem item = CCMenuItemImage.itemFromNormalImage(TestResource.s_PlayNormal, TestResource.s_PlaySelect); CCMenu menu = CCMenu.menuWithItems(item); menu.alignItemsVertically(); menu.position = (new CCPoint(backSize.width / 2, backSize.height / 2)); back.addChild(menu); CCActionInterval rot = CCRotateBy.actionWithDuration(5, 360); CCAction fe = CCRepeatForever.actionWithAction(rot); item.runAction(fe); CCActionInterval move = CCMoveBy.actionWithDuration(3, new CCPoint(200, 0)); CCActionInterval move_back = (CCActionInterval)move.reverse(); CCFiniteTimeAction seq = CCSequence.actions(move, move_back); CCAction fe2 = CCRepeatForever.actionWithAction((CCActionInterval)seq); back.runAction(fe2); }
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); }
/// <summary> /// add submit and cancel button /// </summary> private void AddFormButton() { CCMenuItemImage imagesubmit = CCMenuItemImage.itemFromNormalImage("image/ButtonNormal", "image/ButtonClick", this, AddImageClick); CCLabelTTF textsubmit = CCLabelTTF.labelWithString("确定", "ChineseContent", 28); textsubmit.Color = new ccColor3B(Color.Black); CCMenuItemLabel labelsubmit = CCMenuItemLabel.itemWithLabel(textsubmit); labelsubmit.position = new CCPoint(imagesubmit.contentSize.width / 2, imagesubmit.contentSize.height / 2); imagesubmit.addChild(labelsubmit); CCMenuItemImage imagecancel = CCMenuItemImage.itemFromNormalImage("image/ButtonNormal", "image/ButtonClick", this, AddImageClick); CCLabelTTF textcancel = CCLabelTTF.labelWithString("取消", "ChineseContent", 28); textcancel.Color = new ccColor3B(Color.Black); CCMenuItemLabel labelcancel = CCMenuItemLabel.itemWithLabel(textcancel); labelcancel.position = new CCPoint(imagecancel.contentSize.width / 2, imagecancel.contentSize.height / 2); imagecancel.addChild(labelcancel); CCMenu menu = CCMenu.menuWithItems(imagesubmit, imagecancel); menu.alignItemsHorizontally(); menu.position = new CCPoint(240, m_CurrPostion.y); addChild(menu); m_CurrPostion.y -= imagesubmit.contentSize.height; m_CurrPostion.y -= StillWhite; }
public override void onEnter() { base.onEnter(); CCSize s = CCDirector.sharedDirector().getWinSize(); CCLabelTTF label = CCLabelTTF.labelWithString(title(), "Arial", 32); addChild(label, 1); label.position = (new CCPoint(s.width / 2, s.height - 50)); string strSubtitle = subtitle(); if (!string.IsNullOrEmpty(strSubtitle)) { CCLabelTTF l = CCLabelTTF.labelWithString(strSubtitle, "Arial", 16); addChild(l, 1); l.position = (new CCPoint(s.width / 2, s.height - 80)); } CCMenuItemImage item1 = CCMenuItemImage.itemFromNormalImage(TestResource.s_pPathB1, TestResource.s_pPathB2, this, new SEL_MenuHandler(this.backCallback)); CCMenuItemImage item2 = CCMenuItemImage.itemFromNormalImage(TestResource.s_pPathR1, TestResource.s_pPathR2, this, new SEL_MenuHandler(this.restartCallback)); CCMenuItemImage item3 = CCMenuItemImage.itemFromNormalImage(TestResource.s_pPathF1, TestResource.s_pPathF2, this, new SEL_MenuHandler(this.nextCallback)); CCMenu menu = CCMenu.menuWithItems(item1, item2, item3); 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); addChild(menu, 1); }
public override void onEnter() { base.onEnter(); m_grossini = CCSprite.spriteWithFile(TestResource.s_pPathGrossini); m_tamara = CCSprite.spriteWithFile(TestResource.s_pPathSister1); m_kathia = CCSprite.spriteWithFile(TestResource.s_pPathSister2); addChild(m_grossini, 3); addChild(m_kathia, 2); addChild(m_tamara, 1); CCSize s = CCDirector.sharedDirector().getWinSize(); m_grossini.position = new CCPoint(60, 50); m_kathia.position = new CCPoint(60, 150); m_tamara.position = new CCPoint(60, 250); CCLabelTTF label = CCLabelTTF.labelWithString(title(), "Arial", 32); addChild(label); label.position = new CCPoint(s.width / 2, s.height - 50); CCMenuItemImage item1 = CCMenuItemImage.itemFromNormalImage(TestResource.s_pPathB1, TestResource.s_pPathB2, this, backCallback); CCMenuItemImage item2 = CCMenuItemImage.itemFromNormalImage(TestResource.s_pPathR1, TestResource.s_pPathR2, this, restartCallback); CCMenuItemImage item3 = CCMenuItemImage.itemFromNormalImage(TestResource.s_pPathF1, TestResource.s_pPathF2, this, nextCallback); CCMenu menu = CCMenu.menuWithItems(item1, item2, item3); menu.position = CCPoint.Zero; 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); addChild(menu, 1); }
public TileDemo() { base.isTouchEnabled = true; CCSize s = CCDirector.sharedDirector().getWinSize(); m_label = CCLabelTTF.labelWithString("not", "Arial", 28); addChild(m_label, 1); m_label.position = new CCPoint(s.width / 2, s.height - 50); string strSubtitle = subtitle(); if (strSubtitle == null) { CCLabelTTF l = CCLabelTTF.labelWithString(strSubtitle, "Arial", 16); addChild(l, 1); l.position = new CCPoint(s.width / 2, s.height - 80); m_subtitle = l; } CCMenuItemImage item1 = CCMenuItemImage.itemFromNormalImage(s_pPathB1, s_pPathB2, this, backCallback); CCMenuItemImage item2 = CCMenuItemImage.itemFromNormalImage(s_pPathR1, s_pPathR2, this, restartCallback); CCMenuItemImage item3 = CCMenuItemImage.itemFromNormalImage(s_pPathF1, s_pPathF2, 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); CCMenu menu = CCMenu.menuWithItems(item1, item2, item3); menu.position = new CCPoint(0, 0); addChild(menu, 1); }
public override void onEnter() { base.onEnter(); CCTextureCache.sharedTextureCache().dumpCachedTextureInfo(); CCSize s = CCDirector.sharedDirector().getWinSize(); CCLabelTTF label = CCLabelTTF.labelWithString(title(), "Arial", 26); addChild(label, 1, (int)(enumTag.kTagLabel)); label.position = new CCPoint(s.width / 2, s.height - 50); string strSubtitle = subtitle(); if (strSubtitle.Length > 0) { CCLabelTTF l = CCLabelTTF.labelWithString(strSubtitle, "Arial", 16); addChild(l, 1); l.position = new CCPoint(s.width / 2, s.height - 80); } 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)); CCMenu menu = CCMenu.menuWithItems(item1, item2, item3); 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); addChild(menu, 1); CCTextureCache.sharedTextureCache().dumpCachedTextureInfo(); }
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)); }
/// <summary> /// Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone /// </summary> public override bool init() { CCDirector.sharedDirector().deviceOrientation = ccDeviceOrientation.CCDeviceOrientationLandscapeLeft; ////////////////////////////// // 1. super init first if (!base.init()) { return(false); } this.m_bIsTouchEnabled = true; ///////////////////////////// // 2. add a menu item with "X" image, which is clicked to quit the program // you may modify it. // add a "close" icon to exit the progress. it's an autorelease object CCMenuItemImage pCloseItem = CCMenuItemImage.itemFromNormalImage( "CloseNormal", "CloseSelected", this, new SEL_MenuHandler(menuCloseCallback)); pCloseItem.position = new CCPoint(CCDirector.sharedDirector().getWinSize().width - 20, 20); // create menu, it's an autorelease object CCMenu pMenu = CCMenu.menuWithItems(pCloseItem); pMenu.position = new CCPoint(0, 0); this.addChild(pMenu, 1); ///////////////////////////// // 3. add your codes below... // add a label shows "Hello World" // create and initialize a label CCLabelTTF pLabel = CCLabelTTF.labelWithString("Hello World", "Arial", 24); // ask director the window size CCSize size = CCDirector.sharedDirector().getWinSize(); // position the label on the center of the screen pLabel.position = new CCPoint(size.width / 2, size.height - 50); // add the label as a child to this layer this.addChild(pLabel, 1); // add "HelloWorld" splash screen" CCSprite pSprite = CCSprite.spriteWithFile("HelloWorld"); // position the sprite on the center of the screen pSprite.position = new CCPoint(size.width / 2, size.height / 2); // add the sprite as a child to this layer this.addChild(pSprite, 0); return(true); }
public override bool init() { CCMenuItemImage back_button = CCMenuItemImage.itemFromNormalImage("CloseSelected", "CloseNormal", this, click_back); CCMenu backMenu = CCMenu.menuWithItems(back_button); backMenu.position = new CCPoint(size.width - 20, 40); this.addChild(backMenu); this.m_bIsTouchEnabled = true; this.addChild(actor); return(true); }
public override void onEnter() { base.onEnter(); // Or you can create an sprite using a filename. only PNG is supported now. Probably TIFF too m_grossini = CCSprite.spriteWithFile(TestResource.s_pPathGrossini); m_tamara = CCSprite.spriteWithFile(TestResource.s_pPathSister1); m_kathia = CCSprite.spriteWithFile(TestResource.s_pPathSister2); addChild(m_grossini, 1); addChild(m_tamara, 2); addChild(m_kathia, 3); CCSize s = CCDirector.sharedDirector().getWinSize(); m_grossini.position = new CCPoint(s.width / 2, s.height / 3); m_tamara.position = new CCPoint(s.width / 2, 2 * s.height / 3); m_kathia.position = new CCPoint(s.width / 2, s.height / 2); // add title and subtitle string str = title(); string pTitle = str; CCLabelTTF label = CCLabelTTF.labelWithString(pTitle, "Arial", 18); addChild(label, 1); label.position = new CCPoint(s.width / 2, s.height - 30); string strSubtitle = subtitle(); if (!strSubtitle.Equals("")) { CCLabelTTF l = CCLabelTTF.labelWithString(strSubtitle, "Arial", 22); addChild(l, 1); l.position = new CCPoint(s.width / 2, s.height - 60); } // add menu 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)); CCMenu menu = CCMenu.menuWithItems(item1, item2, item3); 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); addChild(menu, 1); }
private void AddCloseButton() { CCMenuItemImage pCloseItem = CCMenuItemImage.itemFromNormalImage( "Images\\close", "Images\\close", this, new SEL_MenuHandler(menuCloseCallback)); pCloseItem.position = new CCPoint(CCDirector.sharedDirector().getWinSize().width - 20, 20); CCMenu pMenu = CCMenu.menuWithItems(pCloseItem); pMenu.position = new CCPoint(0, 0); this.addChild(pMenu, 1); }
/// <summary> /// add "select image" button /// </summary> private void AddImageButton() { CCMenuItemImage image = CCMenuItemImage.itemFromNormalImage("image/ButtonNormal", "image/ButtonClick", this, AddImageClick); CCLabelTTF text = CCLabelTTF.labelWithString("选择图片", "ChineseContent", 28); text.Color = new ccColor3B(Color.Black); CCMenuItemLabel label = CCMenuItemLabel.itemWithLabel(text); CCMenu menu = CCMenu.menuWithItems(image, label); menu.position = new CCPoint(240, m_CurrPostion.y); addChild(menu); m_CurrPostion.y -= image.contentSize.height; m_CurrPostion.y -= StillWhite; }
/// <summary> /// /// </summary> /// <param name="p_Layer"></param> /// <param name="p_Text"></param> /// <param name="p_LeftButtonPic"></param> /// <param name="p_RightButtonPic"></param> /// <param name="y"></param> public static void AddSetMenu(CCLayer p_Layer, String p_Text, String p_LeftButtonPic, String p_RightButtonPic, SEL_MenuHandler p_LeftHandle, SEL_MenuHandler p_RightHandle, ref float y) { CCLabelTTF language = CCLabelTTF.labelWithString(p_Text, "ChineseTitle", 28); language.Color = new ccColor3B(Color.White); CCMenuItemLabel tab1 = CCMenuItemLabel.itemWithLabel(language); //CCTexture2D cctext2D1 = Media.PictureManager.GetCCTexture2D(p_LeftButtonPic); //CCSprite sprite1 = CCSprite.spriteWithTexture(cctext2D1); CCMenuItemSprite tab2 = CCMenuItemImage.itemFromNormalImage(p_LeftButtonPic, null, p_Layer, p_LeftHandle); //CCTexture2D cctext2D2 = Media.PictureManager.GetCCTexture2D(p_RightButtonPic); // CCSprite sprite2 = CCSprite.spriteWithTexture(cctext2D2); CCMenuItemSprite tab3 = CCMenuItemImage.itemFromNormalImage(p_RightButtonPic, null, p_Layer, p_RightHandle); CCMenu p_Menu1 = CCMenu.menuWithItems(tab1); CCMenu p_Menu2 = CCMenu.menuWithItems(tab2); CCMenu p_Menu3 = CCMenu.menuWithItems(tab3); //position p_Menu2 float textwidth = tab1.contentSize.width < 40 ? 40 : tab1.contentSize.width; float displayCenter = CCDirector.sharedDirector().displaySizeInPixels.width / 2; float x2 = displayCenter - textwidth; float x1 = displayCenter; float x3 = displayCenter + textwidth; float y2 = y + (tab1.contentSize.height - tab2.contentSize.height) / 2; p_Menu2.position = new CCPoint(x2, y2); p_Menu1.position = new CCPoint(x1, y); p_Menu3.position = new CCPoint(x3, y2); p_Layer.addChild(p_Menu2); p_Layer.addChild(p_Menu1); p_Layer.addChild(p_Menu3); y -= tab2.contentSize.height + Blank; }
public TestLayer2() { float x, y; CCSize size = CCDirector.sharedDirector().getWinSize(); x = size.width; y = size.height; CCSprite bg1 = CCSprite.spriteWithFile(TransitionsTestScene.s_back2); bg1.position = new CCPoint(size.width / 2, size.height / 2); addChild(bg1, -1); CCLabelTTF title = CCLabelTTF.labelWithString((TransitionsTestScene.transitions[TransitionsTestScene.s_nSceneIdx]), "Arial", 32); addChild(title); title.Color = new ccColor3B(255, 32, 32); title.position = new CCPoint(x / 2, y - 100); CCLabelTTF label = CCLabelTTF.labelWithString("SCENE 2", "Arial", 38); label.Color = new ccColor3B(16, 16, 255); label.position = new CCPoint(x / 2, y / 2); addChild(label); // menu CCMenuItemImage item1 = CCMenuItemImage.itemFromNormalImage(TransitionsTestScene.s_pPathB1, TransitionsTestScene.s_pPathB2, this, backCallback); CCMenuItemImage item2 = CCMenuItemImage.itemFromNormalImage(TransitionsTestScene.s_pPathR1, TransitionsTestScene.s_pPathR2, this, restartCallback); CCMenuItemImage item3 = CCMenuItemImage.itemFromNormalImage(TransitionsTestScene.s_pPathF1, TransitionsTestScene.s_pPathF2, this, nextCallback); CCMenu menu = CCMenu.menuWithItems(item1, item2, item3); menu.position = new CCPoint(0, 0); item1.position = new CCPoint(x / 2 - 100, 30); item2.position = new CCPoint(x / 2, 30); item3.position = new CCPoint(x / 2 + 100, 30); addChild(menu, 1); schedule(step, 1.0f); }
public override bool init() { bool bRet = false; do { if (!base.init()) { break; } CCSize s = CCDirector.sharedDirector().getWinSize(); CCLabelTTF label = CCLabelTTF.labelWithString(title(), "Arial", 26); addChild(label, 1); label.position = new CCPoint(s.width / 2, s.height - 50); string sSubtitle = subtitle(); if (sSubtitle.Length > 0) { CCLabelTTF l = CCLabelTTF.labelWithString(sSubtitle, "Arial", 16); addChild(l, 1); l.position = new CCPoint(s.width / 2, s.height - 80); } 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)); CCMenu menu = CCMenu.menuWithItems(item1, item2, item3); menu.position = new CCPoint(); 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); bRet = true; } while (false); return(bRet); }
public TestController() { CCDirector.sharedDirector().deviceOrientation = ccDeviceOrientation.CCDeviceOrientationLandscapeLeft; m_tBeginPos = new CCPoint(0.0f, 0.0f); CCSize s = CCDirector.sharedDirector().getWinSize(); // add close menu CCMenuItemImage pCloseItem = CCMenuItemImage.itemFromNormalImage(TestResource.s_pPathClose, TestResource.s_pPathClose, this, new SEL_MenuHandler(closeCallback)); pCloseItem.anchorPoint = new CCPoint(0, 0); CCMenu pMenu = CCMenu.menuWithItems(pCloseItem); pMenu.position = new CCPoint(s.width - 40, 10); // add menu items for tests m_pItemMenu = CCMenu.menuWithItems(null); for (int i = 0; i < (int)(TestCases.TESTS_COUNT); ++i) { // todo, CCMenuItemLabel hasn't been implemented, use CCMenuItemImage instead CCLabelTTF label = CCLabelTTF.labelWithString(Tests.g_aTestNames[i], "Arial", 24); CCMenuItemLabel pMenuItem = CCMenuItemLabel.itemWithLabel(label, this, new SEL_MenuHandler(menuCallback)); //CCMenuItemImage pMenuItem = CCMenuItemImage.itemFromNormalImage(TestResource.s_pPathGrossini, TestResource.s_pPathGrossini, this, new SEL_MenuHandler(menuCallback)); m_pItemMenu.addChild(pMenuItem, i + 10000); pMenuItem.position = new CCPoint(s.width / 2, (s.height - (i + 1) * LINE_SPACE)); } m_pItemMenu.contentSize = new CCSize(s.width, ((int)(TestCases.TESTS_COUNT) + 1) * LINE_SPACE); m_pItemMenu.position = (s_tCurPos); addChild(m_pItemMenu); isTouchEnabled = true; addChild(pMenu, 1); }
public MenuLayer2() { for (int i = 0; i < 2; i++) { CCMenuItemImage item1 = CCMenuItemImage.itemFromNormalImage(s_PlayNormal, s_PlaySelect, this, this.menuCallback); CCMenuItemImage item2 = CCMenuItemImage.itemFromNormalImage(s_HighNormal, s_HighSelect, this, this.menuCallbackOpacity); CCMenuItemImage item3 = CCMenuItemImage.itemFromNormalImage(s_AboutNormal, s_AboutSelect, this, this.menuCallbackAlign); item1.scaleX = 1.5f; item2.scaleX = 0.5f; item3.scaleX = 0.5f; CCMenu menu = CCMenu.menuWithItems(item1, item2, item3); menu.tag = (int)kTag.kTagMenu; addChild(menu, 0, 100 + i); m_centeredMenu = menu.position; } m_alignedH = true; alignMenusH(); }
public Select_employee() { #region UI布置 CCSize size = CCDirector.sharedDirector().getWinSize(); CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFramesWithFile(@"plist/left_right"); base.init(); // 背景 // 开始游戏按钮 CCMenuItemImage star_button = CCMenuItemImage.itemFromNormalImage("UI/PK", "UI/PK1", this, click_star); CCMenu starMenu = CCMenu.menuWithItems(star_button); starMenu.position = new CCPoint(size.width - 60, size.height - 50); this.addChild(starMenu); // 返回按钮 CCMenuItemImage back_button = CCMenuItemImage.itemFromNormalImage("CloseSelected", "CloseNormal", this, click_back); CCMenu backMenu = CCMenu.menuWithItems(back_button); backMenu.position = new CCPoint(size.width - 20, 40); this.addChild(backMenu); // 左右边移动键 CCMenuItemSprite left_button = CCMenuItemSprite.itemFromNormalSprite( CCSprite.spriteWithSpriteFrameName("left_select.png"), CCSprite.spriteWithSpriteFrameName("left.png"), this, left); CCMenuItemSprite right_button = CCMenuItemSprite.itemFromNormalSprite( CCSprite.spriteWithSpriteFrameName("right_select.png"), CCSprite.spriteWithSpriteFrameName("right.png"), this, right); CCMenu select_menu = CCMenu.menuWithItems(left_button, right_button); select_menu.alignItemsHorizontallyWithPadding(440); select_menu.position = new CCPoint(size.width / 2, size.height / 4 * 3); this.addChild(select_menu); #endregion // 员工 }
public virtual void onEnter() { base.onEnter(); CCSize s = CCDirector.sharedDirector().getWinSize(); CCLabelTTF label = CCLabelTTF.labelWithString(title(), "Arial", 28); addChild(label, 1); label.position = new CCPoint(s.width / 2, s.height - 50); CCMenuItemImage item1 = CCMenuItemImage.itemFromNormalImage(s_pPathB1, s_pPathB2, this, backCallback); CCMenuItemImage item2 = CCMenuItemImage.itemFromNormalImage(s_pPathR1, s_pPathR2, this, restartCallback); CCMenuItemImage item3 = CCMenuItemImage.itemFromNormalImage(s_pPathF1, s_pPathF2, this, nextCallback); CCMenu menu = CCMenu.menuWithItems(item1, item2, item3); 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); addChild(menu, 1); }
public TextLayer() { initWithColor(ccTypes.ccc4(32, 32, 32, 255)); float x, y; CCSize size = CCDirector.sharedDirector().getWinSize(); x = size.width; y = size.height; CCNode node = CCNode.node(); CCActionInterval effect = getAction(); node.runAction(effect); addChild(node, 0, EffectTestScene.kTagBackground); CCSprite bg = CCSprite.spriteWithFile(TestResource.s_back3); node.addChild(bg, 0); bg.anchorPoint = new CCPoint(0.5f, 0.5f); bg.position = new CCPoint(size.width / 2, size.height / 2); CCSprite grossini = CCSprite.spriteWithFile(TestResource.s_pPathSister2); node.addChild(grossini, 1); grossini.position = new CCPoint(x / 3, y / 2); CCActionInterval sc = CCScaleBy.actionWithDuration(2, 5); CCFiniteTimeAction sc_back = sc.reverse(); grossini.runAction(CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(sc, sc_back)))); CCSprite tamara = CCSprite.spriteWithFile(TestResource.s_pPathSister1); node.addChild(tamara, 1); tamara.position = new CCPoint(2 * x / 3, y / 2); CCActionInterval sc2 = CCScaleBy.actionWithDuration(2, 5); CCFiniteTimeAction sc2_back = sc2.reverse(); tamara.runAction(CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(sc2, sc2_back)))); CCLabelTTF label = CCLabelTTF.labelWithString(EffectTestScene.effectsList[EffectTestScene.actionIdx], "Arial", 32); label.position = new CCPoint(x / 2, y - 80); addChild(label); label.tag = EffectTestScene.kTagLabel; CCMenuItemImage item1 = CCMenuItemImage.itemFromNormalImage(TestResource.s_pPathB1, TestResource.s_pPathB2, this, backCallback); CCMenuItemImage item2 = CCMenuItemImage.itemFromNormalImage(TestResource.s_pPathR1, TestResource.s_pPathR2, this, restartCallback); CCMenuItemImage item3 = CCMenuItemImage.itemFromNormalImage(TestResource.s_pPathF1, TestResource.s_pPathF2, this, nextCallback); CCMenu menu = CCMenu.menuWithItems(item1, item2, item3); menu.position = new CCPoint(0, 0); item1.position = new CCPoint(size.width / 2 - 100, 30); item2.position = new CCPoint(size.width / 2, 30); item3.position = new CCPoint(size.width / 2 + 100, 30); addChild(menu, 1); schedule(checkAnim); }
/// <summary> /// create textbox item /// </summary> /// <returns></returns> private CCMenuItemImage LoadTextBoxSprite() { return(CCMenuItemImage.itemFromNormalImage("image/TextBox", "image/TextBox", this, NameInput)); }
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); }