public LayerLevels() { //关卡选择层 CCPoint offset = new CCPoint(170, 180); for (int i = 0; i < 4; i++) { for (int j = 0; j < 3; j++) { //关卡的按钮 CCMenuItemSprite level = CCMenuItemSprite.itemFromNormalSprite( CCSprite.spriteWithSpriteFrameName("btn_level1.png"), CCSprite.spriteWithSpriteFrameName("btn_level2.png"), this, click_level); CCMenu menu = CCMenu.menuWithItems(level); //位置相对于左上的UI界面 menu.position = CCDirector.sharedDirector().convertToUI(new CCPoint(offset.x + 160 * i, offset.y + 85 * j)); this.addChild(menu); //创建一个MenuItem,用作文本内容 CCMenuItem menuitem = new CCMenuItem(); //指定Arial的字体描述,保证fonts里有Arial.spritefont var text = CCLabelTTF.labelWithString((j * 4 + i + 1).ToString(), "Arial", 12); //将颜色指定为黑色 text.Color = new ccColor3B(); menuitem.addChild(text); menu.addChild(menuitem); } } }
public Starscene() { base.init(); CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFramesWithFile(@"plist/allimage"); //取得屏幕大小 CCSize size = CCDirector.sharedDirector().getWinSize(); //背景图 CCSprite background = CCSprite.spriteWithFile("background//start"); background.position = new CCPoint(size.width / 2, size.height / 2); this.addChild(background); //两个按钮 CCMenuItemSprite btn_start = CCMenuItemSprite.itemFromNormalSprite( CCSprite.spriteWithSpriteFrameName("playbutton01.png"), CCSprite.spriteWithSpriteFrameName("playbutton03.png"), this, click_start); CCMenuItemSprite btn_back = CCMenuItemSprite.itemFromNormalSprite( CCSprite.spriteWithSpriteFrameName("quitbutton01.png"), CCSprite.spriteWithSpriteFrameName("quitbutton03.png"), this, click_people); //MenuItem需要通过CCMenu组合 CCMenu menu_star = CCMenu.menuWithItems(btn_start); CCMenu menu_back = CCMenu.menuWithItems(btn_back); // 设置开始和结束按钮 menu_star.position = new CCPoint(size.width / 4 * 3 - 60, 70); this.addChild(menu_star); menu_back.position = new CCPoint(size.width / 4 * 3 + 70, 150); this.addChild(menu_back); }
public override bool Init() { if (base.Init()) { // ask director the the window size CCSize size = CCDirector.SharedDirector.WinSize; QuestionContainerSprite question = new QuestionContainerSprite(); QuestionContainerSprite question2 = new QuestionContainerSprite(); question.Init(); question2.Init(); // [question setContentSize:CGSizeMake(50,50)]; // [question2 setContentSize:CGSizeMake(50,50)]; CCMenuItemSprite sprite = new CCMenuItemSprite(question2, question, this, selectAnswer); CCLayerColor layer = new CCLayerColor(new CCColor4B(0, 0, 255, 255), 100, 100); CCLayerColor layer2 = new CCLayerColor(new CCColor4B(255, 0, 0, 255), 100, 100); CCMenuItemSprite sprite2 = new CCMenuItemSprite(layer, layer2, this, selectAnswer); CCMenu menu = new CCMenu(sprite, sprite2, null); menu.AlignItemsVerticallyWithPadding(100); menu.Position = new CCPoint(size.Width / 2, size.Height / 2); // add the label as a child to this Layer AddChild(menu); return(true); } return(false); }
public SelectScene() { base.init(); //取得屏幕大小 CCSize size = CCDirector.sharedDirector().getWinSize(); //背景图 CCSprite background = CCSprite.spriteWithFile("background//select"); background.position = new CCPoint(size.width / 2, size.height / 2); this.addChild(background); // 两个人物的选择 CCMenuItemSprite button_uncle = CCMenuItemSprite.itemFromNormalSprite( CCSprite.spriteWithSpriteFrameName("selectM01.png"), CCSprite.spriteWithSpriteFrameName("selectM02.png"), this, click_start); //两个按钮 CCMenuItemSprite button_kfc = CCMenuItemSprite.itemFromNormalSprite( CCSprite.spriteWithSpriteFrameName("selectK01.png"), CCSprite.spriteWithSpriteFrameName("selectK02.png"), this, click_start); //MenuItem需要通过CCMenu组合 CCMenu menu = CCMenu.menuWithItems(button_uncle, button_kfc); //设置到界面中间偏下 menu.alignItemsHorizontallyWithPadding(120); menu.position = new CCPoint(size.width / 2, size.height / 2 - 20); this.addChild(menu); }
public SceneGame() { base.init(); //背景图 //CCSprite background = CCSprite.spriteWithSpriteFrameName("bg_game.png"); //background.anchorPoint = new CCPoint(0, 0); //this.addChild(background); //地图 CCTMXTiledMap map = CCTMXTiledMap.tiledMapWithTMXFile("TileMaps/Level0"); //map.removeChild(map.layerNamed("units"),false); //取得宽高 CCSize size = CCDirector.sharedDirector().getWinSize(); //保证地图是居中地图显示 map.position = new CCPoint((size.width - map.contentSize.width) / 2, (size.height - map.contentSize.height) / 2); this.addChild(map); //返回按钮 CCMenuItemSprite btn_attack = CCMenuItemSprite.itemFromNormalSprite( CCSprite.spriteWithSpriteFrameName("btn_soldierattack1.png"), CCSprite.spriteWithSpriteFrameName("btn_soldierattack2.png"), this, click_attack); CCMenu menu = CCMenu.menuWithItems(btn_attack); menu.position = new CCPoint(732, 36); this.addChild(menu); }
public SceneStart() { base.init(); //取得屏幕大小 CCSize size = CCDirector.sharedDirector().getWinSize(); //背景图 CCSprite background = CCSprite.spriteWithSpriteFrameName("bg_start.png"); background.anchorPoint = new CCPoint(0, 0); this.addChild(background); //Logo图 CCSprite logo = CCSprite.spriteWithSpriteFrameName("logo.png"); //设置到界面中间偏上 logo.position = new CCPoint(size.width / 2, size.height / 2 + 120); this.addChild(logo); //两个按钮 CCMenuItemSprite btn_start = CCMenuItemSprite.itemFromNormalSprite( CCSprite.spriteWithSpriteFrameName("btn_start1.png"), CCSprite.spriteWithSpriteFrameName("btn_start2.png"), this, click_start); CCMenuItemSprite btn_setting = CCMenuItemSprite.itemFromNormalSprite( CCSprite.spriteWithSpriteFrameName("btn_setting1.png"), CCSprite.spriteWithSpriteFrameName("btn_setting2.png"), this, click_setting); //MenuItem需要通过CCMenu组合 CCMenu menu = CCMenu.menuWithItems(btn_start, btn_setting); //一个垂直间隔排列 menu.alignItemsVerticallyWithPadding(10); //设置到界面中间偏下 menu.position = new CCPoint(size.width / 2, size.height / 2 - 120); this.addChild(menu); }
public SceneStart() { base.init(); #region SanguoCommander2 //取得屏幕大小 CCSize size = CCDirector.sharedDirector().getWinSize(); //背景图 CCSprite background = CCSprite.spriteWithSpriteFrameName("bg_start.png"); background.anchorPoint = new CCPoint(0, 0); this.addChild(background); //Logo图 CCSprite logo = CCSprite.spriteWithSpriteFrameName("logo.png"); //设置到界面中间偏上 logo.position = new CCPoint(size.width / 2, size.height / 2 + 120); this.addChild(logo); //两个按钮 CCMenuItemSprite btn_start = CCMenuItemSprite.itemFromNormalSprite( CCSprite.spriteWithSpriteFrameName("btn_start1.png"), CCSprite.spriteWithSpriteFrameName("btn_start2.png"), this, click_start); CCMenuItemSprite btn_setting = CCMenuItemSprite.itemFromNormalSprite( CCSprite.spriteWithSpriteFrameName("btn_setting1.png"), CCSprite.spriteWithSpriteFrameName("btn_setting2.png"), this, click_setting); //MenuItem需要通过CCMenu组合 CCMenu menu = CCMenu.menuWithItems(btn_start, btn_setting); //一个垂直间隔排列 menu.alignItemsVerticallyWithPadding(10); //设置到界面中间偏下 menu.position = new CCPoint(size.width / 2, size.height / 2 - 120); this.addChild(menu); #endregion //测试动画的角色 List <string> id_buff = new List <string>() { "B1", "B2", "B3", "B4", "Hero02", "A1", "A2", "A3", "A4", "Hero11" }; for (int i = 0; i < 2; i++) { for (int j = 0; j < 5; j++) { var actor = new ActorBase(new ActorData(id_buff[i * 5 + j])); actor.ActorDir = (ActorDir)(i + 1); actor.position = new CCPoint(64 + i * 64, 64 + j * 64); //单数为站立动作,双数为攻击动作 if (j % 2 == 1) { actor.StateToRun(); } else { actor.StateToAttack(); } //添加角色 this.addChild(actor); } } // }
public override bool init() { if (base.init()) { // ask director the the window size CCSize size = CCDirector.sharedDirector().getWinSize(); QuestionContainerSprite question = new QuestionContainerSprite(); QuestionContainerSprite question2 = new QuestionContainerSprite(); question.init(); question2.init(); // [question setContentSize:CGSizeMake(50,50)]; // [question2 setContentSize:CGSizeMake(50,50)]; CCMenuItemSprite sprite = CCMenuItemSprite.itemFromNormalSprite(question2, question, this, selectAnswer); CCLayerColor layer = CCLayerColor.layerWithColorWidthHeight(new ccColor4B(0, 0, 255, 255), 100, 100); CCLayerColor layer2 = CCLayerColor.layerWithColorWidthHeight(new ccColor4B(255, 0, 0, 255), 100, 100); CCMenuItemSprite sprite2 = CCMenuItemSprite.itemFromNormalSprite(layer, layer2, this, selectAnswer); CCMenu menu = CCMenu.menuWithItems(sprite, sprite2, null); menu.alignItemsVerticallyWithPadding(100); menu.position = new CCPoint(size.width / 2, size.height / 2); // add the label as a child to this Layer addChild(menu); return(true); } return(false); }
public SceneSelect() { base.init(); //背景图 CCSprite background = CCSprite.spriteWithSpriteFrameName("bg_select.png"); background.anchorPoint = new CCPoint(0, 0); this.addChild(background); //返回按钮 CCMenuItemSprite btn_back = CCMenuItemSprite.itemFromNormalSprite( CCSprite.spriteWithSpriteFrameName("btn_back1.png"), CCSprite.spriteWithSpriteFrameName("btn_back2.png"), this, click_back); CCMenu menu = CCMenu.menuWithItems(btn_back); menu.position = new CCPoint(666, 32); this.addChild(menu); //上面的Tab按钮 CCSprite tab1 = CCSprite.spriteWithSpriteFrameName("tab_shu1.png"); CCSprite tab2 = CCSprite.spriteWithSpriteFrameName("tab_wu2.png"); CCSprite tab3 = CCSprite.spriteWithSpriteFrameName("tab_wei2.png"); tab1.position = new CCPoint(115, 430); tab2.position = new CCPoint(335, 430); tab3.position = new CCPoint(575, 430); this.addChild(tab1); this.addChild(tab2); this.addChild(tab3); CCPoint offset = new CCPoint(150, 150); for (int i = 0; i < 4; i++) { for (int j = 0; j < 3; j++) { CCMenuItemSprite level = CCMenuItemSprite.itemFromNormalSprite( CCSprite.spriteWithSpriteFrameName("btn_level1.png"), CCSprite.spriteWithSpriteFrameName("btn_level2.png"), this, click_level); menu = CCMenu.menuWithItems(level); menu.position = new CCPoint(offset.x + 160 * i, offset.y + 85 * j); this.addChild(menu); } } }
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 SceneGame() { base.init(); //±³¾°Í¼ CCSprite background = CCSprite.spriteWithSpriteFrameName("bg_game.png"); background.anchorPoint = new CCPoint(0, 0); this.addChild(background); //·µ»Ø°´Å¥ CCMenuItemSprite btn_attack = CCMenuItemSprite.itemFromNormalSprite( CCSprite.spriteWithSpriteFrameName("btn_soldierattack1.png"), CCSprite.spriteWithSpriteFrameName("btn_soldierattack2.png"), this, click_attack); CCMenu menu = CCMenu.menuWithItems(btn_attack); menu.position = new CCPoint(732, 36); this.addChild(menu); }
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)(new CCSequence(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); }
/// <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 Layer3() { CCMenuItemFont.DefaultFontName = "Marker Felt"; CCMenuItemFont.DefaultFontSize = 28; CCLabelBMFont label = new CCLabelBMFont("Enable AtlasItem", "bitmapFontTest3.fnt"); CCMenuItemLabel item1 = new CCMenuItemLabel(label, this, new MonoMac.ObjCRuntime.Selector("menuCallback2:")); CCMenuItemFont item2 = new CCMenuItemFont("--- Go Back ---", this, new MonoMac.ObjCRuntime.Selector("menuCallback:")); CCSprite spriteNormal = new CCSprite ("menuitemsprite.png", new RectangleF (0, 23 * 2, 115, 23)); CCSprite spriteSelected = new CCSprite ("menuitemsprite.png", new RectangleF (0, 23 * 1, 115, 23)); CCSprite spriteDisabled = new CCSprite ("menuitemsprite.png", new RectangleF (0, 23 * 0, 115, 23)); CCMenuItemSprite item3 = new CCMenuItemSprite (spriteNormal, spriteSelected, spriteDisabled, this, new MonoMac.ObjCRuntime.Selector("menuCallback3:")); disabledItem = item3; disabledItem.Enabled = false; NSArray arrayOfItems = NSArray.FromObjects(item1, item2, item3); CCMenu menu = new CCMenu(arrayOfItems); CGSize 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); var jump = new CCJumpBy(3, new CCPoint(400,0), 50, 4); item2.RunAction (new CCRepeatForever ((CCActionInterval)CCSequence.Actions (jump, jump.Reverse ()))); var spin1 = new CCRotateBy (3, 360); var spin2 = (CCRotateBy)spin1.Copy (); var spin3 = (CCRotateBy)spin1.Copy (); item1.RunAction (new CCRepeatForever (spin1)); item2.RunAction (new CCRepeatForever (spin2)); item3.RunAction (new CCRepeatForever (spin3)); this.AddChild (menu); menu.Position = new CCPoint(0, 0); }
public SceneOver() { base.init(); //±³¾°Í¼ CCSprite background = CCSprite.spriteWithSpriteFrameName("bg_over.png"); background.anchorPoint = new CCPoint(0, 0); this.addChild(background); //ÎÄ×Ö CCSprite title = CCSprite.spriteWithSpriteFrameName("text_over.png"); title.position = new CCPoint(CCDirector.sharedDirector().getWinSize().width / 2, CCDirector.sharedDirector().getWinSize().height / 2 + 150); this.addChild(title); //·µ»Ø°´Å¥ CCMenuItemSprite btn_back = CCMenuItemSprite.itemFromNormalSprite( CCSprite.spriteWithSpriteFrameName("btn_back1.png"), CCSprite.spriteWithSpriteFrameName("btn_back2.png"), this, click_back); CCMenu menu = CCMenu.menuWithItems(btn_back); menu.position = new CCPoint(666, 32); this.addChild(menu); }
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 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 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); }
public MenuTest() { CCDirector director = CCDirector.SharedDirector (); SizeF size = director.WinSize (); CCMenu menu = null; CCSprite spriteNormal = new CCSprite ("menuitemsprite.png", new RectangleF (0, 23 * 2, 115, 23)); CCSprite spriteSelected = new CCSprite ("menuitemsprite.png", new RectangleF (0, 23 * 1, 115, 23)); CCSprite spriteDisabled = new CCSprite ("menuitemsprite.png", new RectangleF (0, 23 * 0, 115, 23)); CCMenuItemSprite item1 = new CCMenuItemSprite (spriteNormal, spriteSelected, spriteDisabled, delegate (NSObject sender) { CCScene scene1 = new CCScene (); scene1.AddChild (Layer2.Node()); CCDirector.SharedDirector ().ReplaceScene (scene1); }); CCMenuItemImage item2 = new CCMenuItemImage ("SendScoreButton.png", "SendScoreButtonPressed.png", null, cb); CCLabelAtlas labelAtlas = new CCLabelAtlas ("0123456789", "fps_images.png", 12, 32, '.'); CCMenuItemLabel item3 = new CCMenuItemLabel(labelAtlas, delegate (NSObject sender) { CCDirector.SharedDirector ().EventDispatcher.AddMouseDelegate (this, -128-1); this.Schedule (new MonoMac.ObjCRuntime.Selector ("allowTouches"), 5.0f); }); item3.DisabledColor = new ccColor3B (32, 32, 64); item3.Color = new ccColor3B (200, 200, 255); disabledItem = item3; CCMenuItemFont item4 = new CCMenuItemFont ("I toggle enabled items", delegate { disabledItem.Enabled = !disabledItem.Enabled; } ); item4.FontSize = 20; item4.FontName = "Marker Felt"; CCLabelBMFont label = new CCLabelBMFont ("configuration", "bitmapFontTest3.fnt"); CCMenuItemLabel item5 = new CCMenuItemLabel (label, delegate { CCScene scene = new CCScene (); scene.AddChild (new Layer4 ()); CCDirector.SharedDirector ().ReplaceScene (scene); }); item5.Scale = 0.8f; CCMenuItemFont.DefaultFontName = "Marker Felt"; CCMenuItemFont item6 = new CCMenuItemFont ("Priority Test", delegate (NSObject sender) { CCScene scene = new CCScene(); scene.AddChild (new LayerPriorityTest()); CCDirector.SharedDirector ().PushScene (scene); }); CCMenuItemFont.DefaultFontName = "Courier New"; CCMenuItemFont.DefaultFontSize = 30; CCMenuItemFont item7 = new CCMenuItemFont ("Quit", delegate { director.View.Window.Close (); }); CCTintBy color_action = new CCTintBy(0.5f, 0, -255, -255); var color_back = color_action.Reverse (); var seq = new CCSequence (color_action, color_back); item7.RunAction (new CCRepeatForever (seq)); menu = new CCMenu (item1, item2, item3, item4, item5, item6, item7); menu.AlignItemsVertically (); for (uint i = 0; i < menu.Children.Count(); i++) { CCNode child = (CCNode)menu.Children.ObjectAtIndex(i); PointF dstPoint = child.Position; int offset = (int)(size.Width/2) + 50; if (i % 2 == 0) offset = -offset; child.Position = new PointF(dstPoint.X + offset, dstPoint.Y); child.RunAction(new CCEaseElasticOut( new CCMoveBy(2, new PointF(dstPoint.X - offset, 0)), 0.35f)); } menu.Position = new PointF(size.Width/2, size.Height/2); this.AddChild(menu); }
public SceneSelect() { base.init(); #region SanguoCommander4 //背景图 CCSprite background = CCSprite.spriteWithSpriteFrameName("bg_select.png"); background.anchorPoint = new CCPoint(0, 0); this.addChild(background); //返回按钮 CCMenuItemSprite btn_back = CCMenuItemSprite.itemFromNormalSprite( CCSprite.spriteWithSpriteFrameName("btn_back1.png"), CCSprite.spriteWithSpriteFrameName("btn_back2.png"), this, click_back); CCMenu menu = CCMenu.menuWithItems(btn_back); menu.position = new CCPoint(666, 32); this.addChild(menu); //上面的Tab按钮创建 CCMenuItemSprite tab1 = CCMenuItemSprite.itemFromNormalSprite( CCSprite.spriteWithSpriteFrameName("tab_shu2.png"), CCSprite.spriteWithSpriteFrameName("tab_shu1.png"), CCSprite.spriteWithSpriteFrameName("tab_shu1.png"), this, click_story_tab); CCMenuItemSprite tab2 = CCMenuItemSprite.itemFromNormalSprite( CCSprite.spriteWithSpriteFrameName("tab_wu2.png"), CCSprite.spriteWithSpriteFrameName("tab_wu1.png"), CCSprite.spriteWithSpriteFrameName("tab_wu1.png"), this, click_story_tab); CCMenuItemSprite tab3 = CCMenuItemSprite.itemFromNormalSprite( CCSprite.spriteWithSpriteFrameName("tab_wei2.png"), CCSprite.spriteWithSpriteFrameName("tab_wei1.png"), CCSprite.spriteWithSpriteFrameName("tab_wei1.png"), this, click_story_tab); story_tabs = CCMenu.menuWithItems(tab1, tab2, tab3); //按照水平方向10个像素间隔分割 story_tabs.alignItemsHorizontallyWithPadding(10); //转换为界面UI的坐标 story_tabs.position = CCDirector.sharedDirector().convertToUI(new CCPoint(300, 72)); //将第一个设置为不可点击 tab1.Enabled = false; this.addChild(story_tabs); //添加测试层 //this.addChild(new LayerLevels()); //将标签对应到不同的LyerLevers 类中 dictLayerLevels.Add(tab1, new LayerLevels() { visible = false }); dictLayerLevels.Add(tab2, new LayerLevels() { visible = false }); dictLayerLevels.Add(tab3, new LayerLevels() { visible = false }); //将tab1显示为当前的关卡层 showLayerLevels(dictLayerLevels[tab1]); //遍历并添加到界面中 foreach (var item in dictLayerLevels.Values) { this.addChild(item); } #endregion }