//--------------------------------------------------------------------------------------------------------- // SetupUI //--------------------------------------------------------------------------------------------------------- // Sets up the game UI //--------------------------------------------------------------------------------------------------------- void SetupUI(CCRect bounds) { var titleLabel = new CCLabel("Free Play Placeholder", GOTHIC_44_HD_FNT) { AnchorPoint = CCPoint.AnchorMiddle, Scale = 1.5f, Position = bounds.Center }; AddChild(titleLabel); backLabel = new CCLabel("Back", GOTHIC_44_HD_FNT) { AnchorPoint = CCPoint.AnchorMiddle, Scale = 1.5f, }; var backItem = new CCMenuItemLabel(backLabel, BackToGameSelect); var backMenu = new CCMenu(backItem); backMenu.AnchorPoint = CCPoint.AnchorMiddleBottom; backMenu.Position = new CCPoint(bounds.Size.Width / 2, 220f); AddChild(backMenu); }
public override bool init() { if (base.init()) { CCSize s = CCDirector.sharedDirector().getWinSize(); CCLayerColor background = CCLayerColor.layerWithColor(new ccColor4B(255, 0, 255, 255)); addChild(background); CCLayerColor sprite_a = CCLayerColor.layerWithColorWidthHeight(new ccColor4B(255, 0, 0, 255), 700, 700); sprite_a.anchorPoint = new CCPoint(0.5f, 0.5f); sprite_a.isRelativeAnchorPoint = true; sprite_a.position = new CCPoint(0.0f, s.height / 2); addChild(sprite_a); sprite_a.runAction(CCRepeatForever.actionWithAction((CCActionInterval)CCSequence.actions( CCMoveTo.actionWithDuration(1.0f, new CCPoint(1024.0f, 384.0f)), CCMoveTo.actionWithDuration(1.0f, new CCPoint(0.0f, 384.0f))))); CCLayerColor sprite_b = CCLayerColor.layerWithColorWidthHeight(new ccColor4B(0, 0, 255, 255), 400, 400); sprite_b.anchorPoint = new CCPoint(0.5f, 0.5f); sprite_b.isRelativeAnchorPoint = true; sprite_b.position = new CCPoint(s.width / 2, s.height / 2); addChild(sprite_b); CCMenuItemLabel label = CCMenuItemLabel.itemWithLabel(CCLabelTTF.labelWithString("Flip Me", "Helvetica", 24), this, callBack); CCMenu menu = CCMenu.menuWithItems(label); menu.position = new CCPoint(s.width - 200.0f, 50.0f); addChild(menu); return(true); } return(false); }
public YesNoDialog(string title, string content, Action <object> yes, Action <object> no) { _title = new MenuItemNoActionLable(new CCLabel(title, "arial", 40)) { //Position=new CCPoint(GlobalGameData.Window_Center_X,GlobalGameData.Window_Center_Y+50), Color = CCColor3B.White, }; _content = new MenuItemNoActionLable(new CCLabel(content, "arial", 20)) { //Position=new CCPoint(GlobalGameData.Window_Center_X,GlobalGameData.Window_Center_Y), Color = CCColor3B.White, }; _yes = new CCMenuItemLabel(new CCLabel("はい", "arial", 50) { // Position = new CCPoint(GlobalGameData.Window_Center_X, GlobalGameData.Window_Center_Y) }, yes); _no = new CCMenuItemLabel(new CCLabel("いいえ", "arial", 50) { //Position = new CCPoint(GlobalGameData.Window_Center_X, GlobalGameData.Window_Center_Y) }, no); int margin = 10; var drawNode_height = _title.ContentSize.Height + _content.ContentSize.Height + _yes.ContentSize.Height + 3 * margin; var drawNode_width = 2 * margin + _content.ContentSize.Width; var _drawNode = new CCDrawNode(); _drawNode.DrawRect(new CCRect(GlobalGameData.Window_Center_X, GlobalGameData.Window_Center_Y, drawNode_width, drawNode_height), CCColor4B.White); // _backGround = _drawNode; }
/// <summary> /// 菜单初始化 /// </summary> private void MenuInit() { CCLabelTTF startlabel = CCLabelTTF.labelWithString("开始", "ChineseTitle", 28); CCLabelTTF settinglabel = CCLabelTTF.labelWithString("选项", "ChineseTitle", 28); CCLabelTTF listwordlabel = CCLabelTTF.labelWithString("词库列表", "ChineseTitle", 28); CCLabelTTF addwordlabel = CCLabelTTF.labelWithString("添加词", "ChineseTitle", 28); CCLabelTTF endlabel = CCLabelTTF.labelWithString("结束", "ChineseTitle", 28); CCMenuItemLabel startbutton = CCMenuItemLabel.itemWithLabel(startlabel, this, this.StartCallback); CCMenuItemLabel settingbutton = CCMenuItemLabel.itemWithLabel(settinglabel, this, this.SettingCallback); CCMenuItemLabel managebutton = CCMenuItemLabel.itemWithLabel(listwordlabel, this, this.WordListClick); CCMenuItemLabel addwordbutton = CCMenuItemLabel.itemWithLabel(addwordlabel, this, this.WordAddClick); CCMenuItemLabel endbutton = CCMenuItemLabel.itemWithLabel(endlabel, this, this.closeCallback); startbutton.Color = new ccColor3B(Color.Black); settingbutton.Color = new ccColor3B(Color.Black); managebutton.Color = new ccColor3B(Color.Black); endbutton.Color = new ccColor3B(Color.Black); addwordbutton.Color = new ccColor3B(Color.Black); CCMenu menu = CCMenu.menuWithItems(startbutton, settingbutton, managebutton, addwordbutton, endbutton); menu.alignItemsInColumns(1, 1, 1, 1, 1); addChild(menu, 1); }
private void CreateQuestionLanguage(CCMenu p_Menu) { CCLabelTTF label = CCLabelTTF.labelWithString("发音", "ChineseTitle", 28); label.Color = new ccColor3B(Color.White); CCMenuItemLabel tab = CCMenuItemLabel.itemWithLabel(label); }
protected override void AddedToScene() { base.AddedToScene(); CCMenuItemFont.FontSize = 50; CCMenuItemFont.FontName = "arial"; CCMenuItemFont title1 = new CCMenuItemFont("Easing Style"); title1.Enabled = false; CCMenuItemFont.FontSize = 50; var items = from s in _easings select new CCMenuItemFont(s.Key); var easingTypes = new CCMenuItemToggle(this.menuCallback, items.ToArray()); var label = new CCLabel("StartGame", "Arial", 50, CCLabelFormat.SystemFont); var back = new CCMenuItemLabel(label, this.backCallback); CCMenu menu = new CCMenu( title1, easingTypes, back) { Tag = 36 }; // 9 items. menu.AlignItemsInColumns(2, 2, 2, 2, 1); AddChild(menu); }
public override bool Init() { if (base.Init()) { CCSize s = CCDirector.SharedDirector.WinSize; CCLayerColor background = new CCLayerColor(new CCColor4B(255, 0, 255, 255)); AddChild(background); CCLayerColor sprite_a = new CCLayerColor(new CCColor4B(255, 0, 0, 255), 700, 700); sprite_a.AnchorPoint = new CCPoint(0.5f, 0.5f); sprite_a.IgnoreAnchorPointForPosition = true; sprite_a.Position = new CCPoint(0.0f, s.Height / 2); AddChild(sprite_a); sprite_a.RunAction(new CCRepeatForever((CCActionInterval)CCSequence.FromActions( new CCMoveTo(1.0f, new CCPoint(1024.0f, 384.0f)), new CCMoveTo(1.0f, new CCPoint(0.0f, 384.0f))))); CCLayerColor sprite_b = new CCLayerColor(new CCColor4B(0, 0, 255, 255), 400, 400); sprite_b.AnchorPoint = new CCPoint(0.5f, 0.5f); sprite_b.IgnoreAnchorPointForPosition = true; sprite_b.Position = new CCPoint(s.Width / 2, s.Height / 2); AddChild(sprite_b); CCMenuItemLabel label = new CCMenuItemLabel(new CCLabelTTF("Flip Me", "Helvetica", 24), callBack); CCMenu menu = new CCMenu(label); menu.Position = new CCPoint(s.Width - 200.0f, 50.0f); AddChild(menu); return(true); } return(false); }
public LayerGradient() { //gradientLayer = new CCLayerGradient(new CCColor4B(255, 0, 0, 255), new CCColor4B(0, 255, 0, 255), new CCPoint(0.9f, 0.9f)); gradientLayer = new CCLayerGradient(CCColor4B.Red, CCColor4B.Green); gradientLayer.UpdateColor(); //gradientLayer.StartOpacity = 127; //gradientLayer.EndOpacity = 127; AddChild(gradientLayer, 0, kTagLayer); // Register Touch Event var touchListener = new CCEventListenerTouchAllAtOnce(); touchListener.OnTouchesMoved = onTouchesMoved; AddEventListener(touchListener); var label1 = new CCLabel("Compressed Interpolation: Enabled", "arial", 26, CCLabelFormat.SpriteFont); var label2 = new CCLabel("Compressed Interpolation: Disabled", "arial", 26, CCLabelFormat.SpriteFont); var item1 = new CCMenuItemLabel(label1); var item2 = new CCMenuItemLabel(label2); var item = new CCMenuItemToggle((toggleItem), item1, item2); menu = new CCMenu(item); AddChild(menu); }
private void InitBug1159Layer() { CCSize s = Layer.VisibleBoundsWorldspace.Size; CCLayerColor background = new CCLayerColor(new CCColor4B(255, 0, 255, 255)); AddChild(background); CCLayerColor sprite_a = new CCLayerColor(new CCColor4B(255, 0, 0, 255)); sprite_a.AnchorPoint = new CCPoint(0.5f, 0.5f); sprite_a.IgnoreAnchorPointForPosition = true; sprite_a.Position = new CCPoint(0.0f, s.Height / 2); AddChild(sprite_a); sprite_a.RunAction(new CCRepeatForever((CCFiniteTimeAction) new CCSequence( new CCMoveTo(1.0f, new CCPoint(1024.0f, 384.0f)), new CCMoveTo(1.0f, new CCPoint(0.0f, 384.0f))))); CCLayerColor sprite_b = new CCLayerColor(new CCColor4B(0, 0, 255, 255)); sprite_b.AnchorPoint = new CCPoint(0.5f, 0.5f); sprite_b.IgnoreAnchorPointForPosition = true; sprite_b.Position = new CCPoint(s.Width / 2, s.Height / 2); AddChild(sprite_b); CCMenuItemLabel label = new CCMenuItemLabel(new CCLabel("Flip Me", "Helvetica", 24, CCLabelFormat.SpriteFont), callBack); CCMenu menu = new CCMenu(label); menu.Position = new CCPoint(s.Width - 200.0f, 50.0f); AddChild(menu); }
/// <summary> /// add chinese input item /// </summary> private void AddEnglishItem() { CCMenuItemImage image = LoadTextBoxSprite(); CCLabelTTF text = CCLabelTTF.labelWithString("英文", "ChineseTitle", 28); text.Color = new ccColor3B(Color.Black); CCMenuItemLabel label = CCMenuItemLabel.itemWithLabel(text); m_EnglishLabel = CreateTextLabel(Language.Enlish, String.Empty); m_EnglishLabel.Color = new ccColor3B(Color.Black); CCMenuItemLabel content = CCMenuItemLabel.itemWithLabel(m_EnglishLabel); content.position = new CCPoint(10, 0); image.addChild(content); CCMenu menu = CCMenu.menuWithItems(label, image); menu.alignItemsHorizontallyWithPadding(50); menu.position = new CCPoint(240, m_CurrPostion.y); addChild(menu); m_CurrPostion.y -= image.contentSize.height; m_CurrPostion.y -= StillWhite; }
/// <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; }
protected override void AddedToScene() { base.AddedToScene(); var s = VisibleBoundsWorldspace.Size; var left = new CCPoint(s.Width / 4, s.Height / 2); var right = new CCPoint(s.Width / 4 * 3, s.Height / 2); var sp1 = new CCSprite("Images/grossini.png"); sp1.Position = new CCPoint(left); var move1 = new CCMoveBy(1, new CCPoint(s.Width / 2, 0)); AddChild(sp1); sp1.RepeatForever(move1, move1.Reverse()); var sp2 = new CCSprite("Images/grossinis_sister1.png"); sp2.Position = new CCPoint(right); var move2 = new CCMoveBy(1, new CCPoint(-s.Width / 2, 0)); AddChild(sp2); sp2.RepeatForever(move2, move2.Reverse()); var label1 = new CCLabel("capture all", "fonts/arial", 24, CCLabelFormat.SpriteFont); var mi1 = new CCMenuItemLabel(label1, OnCapture); var menu = new CCMenu(mi1); AddChild(menu); menu.Position = new CCPoint(s.Width / 2, s.Height / 4); }
//--------------------------------------------------------------------------------------------------------- // AddedToScene //--------------------------------------------------------------------------------------------------------- protected override void AddedToScene() { base.AddedToScene(); // Use the bounds to layout the positioning of our drawable assets CCRect bounds = VisibleBoundsWorldspace; Bubbles = new CCNode(); AddChild(Bubbles); //initialize every bool in BubbleArray to false. True if there is a bubble there. for (int i = 0; i < MAX_BUBBLES_X; i++) { BubbleOccupiedArray [i] = false; } // branches = ReadBranches (branchInfo); // levels = ReadLevels (levelInfo); //--------------------------------------------------------------------------------------------------------- //Menu Elements //--------------------------------------------------------------------------------------------------------- startLabel = new CCLabel("Start", GOTHIC_44_HD_FNT); startLabel.AnchorPoint = CCPoint.AnchorMiddle; startLabel.Scale = 2.0f; var menuItemStart = new CCMenuItemLabel(startLabel, Start); creditsLabel = new CCLabel("Credits", GOTHIC_44_HD_FNT); creditsLabel.AnchorPoint = CCPoint.AnchorMiddle; creditsLabel.Scale = 2.0f; var menuItemCredits = new CCMenuItemLabel(creditsLabel, Credits); var menu = new CCMenu(menuItemStart, menuItemCredits) { Position = new CCPoint(bounds.Size.Width / 2, bounds.Size.Height / 2.3f), AnchorPoint = CCPoint.AnchorMiddle }; menu.AlignItemsVertically(250); AddChild(menu); rtLogo = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("bb_retrotek.png"))); rtLogo.AnchorPoint = CCPoint.AnchorMiddle; rtLogo.Position = new CCPoint(bounds.Size.Width / 2, bounds.Size.Height / 14); //rtLogo.RunAction (repeatedAction); AddChild(rtLogo); title = new CCSprite(uiSpriteSheet.Frames.Find(x => x.TextureFilename.Equals("bb_title.png"))); title.AnchorPoint = CCPoint.AnchorMiddle; title.Position = new CCPoint(bounds.Size.Width / 2, (bounds.Size.Height / 7) * 6); title.RunAction(repeatedAction); AddChild(title); Schedule(_ => CheckForFadedBubbles()); }
public CocosDenshionTest() { m_pItmeMenu = null; m_tBeginPos = new CCPoint(0, 0); m_nSoundId = 0; string[] testItems = { "play background music", "stop background music", "pause background music", "resume background music", "rewind background music", "is background music playing", "play effect", "play effect repeatly", "stop effect", "unload effect", "add background music volume", "sub background music volume", "add effects volume", "sub effects volume" }; // add menu items for tests m_pItmeMenu = CCMenu.menuWithItems(null); CCSize s = CCDirector.sharedDirector().getWinSize(); m_nTestCount = testItems.Count <string>(); for (int i = 0; i < m_nTestCount; ++i) { CCLabelTTF label = CCLabelTTF.labelWithString(testItems[i], "Arial", 24); CCMenuItemLabel pMenuItem = CCMenuItemLabel.itemWithLabel(label, this, new SEL_MenuHandler(menuCallback)); m_pItmeMenu.addChild(pMenuItem, i + 10000); pMenuItem.position = new CCPoint(s.width / 2, (s.height - (i + 1) * LINE_SPACE)); } m_pItmeMenu.contentSize = new CCSize(s.width, (m_nTestCount + 1) * LINE_SPACE); m_pItmeMenu.position = new CCPoint(0, 0); addChild(m_pItmeMenu); this.isTouchEnabled = true; // preload background music and effect SimpleAudioEngine.sharedEngine().preloadBackgroundMusic(CCFileUtils.fullPathFromRelativePath(MUSIC_FILE)); SimpleAudioEngine.sharedEngine().preloadEffect(CCFileUtils.fullPathFromRelativePath(EFFECT_FILE)); // set default volume SimpleAudioEngine.sharedEngine().setEffectsVolume(0.5f); SimpleAudioEngine.sharedEngine().setBackgroundMusicVolume(0.5f); }
public CocosDenshionTest() { m_pItmeMenu = null; m_tBeginPos = new CCPoint(0, 0); m_nSoundId = 0; string[] testItems = { "play background music", "stop background music", "pause background music", "resume background music", "rewind background music", "is background music playing", "play effect", "play effect repeatly", "stop effect", "unload effect", "add background music volume", "sub background music volume", "add effects volume", "sub effects volume" }; // add menu items for tests m_pItmeMenu = new CCMenu(null); CCSize s = CCDirector.SharedDirector.WinSize; m_nTestCount = testItems.Count <string>(); for (int i = 0; i < m_nTestCount; ++i) { CCLabelTTF label = new CCLabelTTF(testItems[i], "arial", 24); CCMenuItemLabel pMenuItem = new CCMenuItemLabel(label, menuCallback); m_pItmeMenu.AddChild(pMenuItem, i + 10000); pMenuItem.Position = new CCPoint(s.Width / 2, (s.Height - (i + 1) * LINE_SPACE)); } m_pItmeMenu.ContentSize = new CCSize(s.Width, (m_nTestCount + 1) * LINE_SPACE); m_pItmeMenu.Position = new CCPoint(0, 0); AddChild(m_pItmeMenu); this.TouchEnabled = true; // preload background music and effect CCSimpleAudioEngine.SharedEngine.PreloadBackgroundMusic(CCFileUtils.FullPathFromRelativePath(MUSIC_FILE)); CCSimpleAudioEngine.SharedEngine.PreloadEffect(CCFileUtils.FullPathFromRelativePath(EFFECT_FILE)); // set default volume CCSimpleAudioEngine.SharedEngine.EffectsVolume = 0.5f; CCSimpleAudioEngine.SharedEngine.BackgroundMusicVolume = 0.5f; }
public Button(string label, CCNode parent, ButtonClickDelegate d) { _label = label; _parent = parent; _onClick = d; CCLabelTTF ttf = CCLabelTTF.labelWithString(label, "Arial", 32f); CCMenuItemLabel item = CCMenuItemLabel.itemWithLabel(ttf, null, new SEL_MenuHandler(d)); CCMenu pMenu = CCMenu.menuWithItems(item); pMenu.position = new CCPoint(0, 0); addChild(pMenu); }
protected override void AddedToScene() { base.AddedToScene(); var label = new CCLabel("Go To Menu", "Arial", 50, CCLabelFormat.SystemFont); var back = new CCMenuItemLabel(label, this.backCallback); CCMenu menu = new CCMenu(back) { Tag = 36 }; // 9 items. back.PositionY = -250; back.PositionX = 0; AddChild(menu); }
/// <summary> /// delete one word with user click /// </summary> public void DeleteClick(CCObject pSender) { CCMenuItemLabel label = pSender as CCMenuItemLabel; if (null != label && null != label.userData) { Word word = label.userData as Word; if (DataBaseManager.Delete(word.Id)) { DataManager.RefreshWords(); WordListScene wms = new WordListScene(); wms.Run(this.position); } } }
/// <summary> /// AddTitleMenu only text /// </summary> /// <param name="p_Layer">current CCLayer</param> /// <param name="p_TitleText">show text</param> /// <param name="y">current y</param> public static void AddTitleMenu(CCLayer p_Layer, String p_TitleText, ref float y) { CCLabelTTF label = CCLabelTTF.labelWithString(p_TitleText, "ChineseTitle", 28); label.Color = new ccColor3B(Color.White); CCMenuItemLabel tab = CCMenuItemLabel.itemWithLabel(label); CCMenu menu = CCMenu.menuWithItems(tab); menu.position = new CCPoint(CCDirector.sharedDirector().displaySizeInPixels.width / 2, y); //menu.position.y = p_CurrPoint.y; y -= tab.contentSize.height + Blank; p_Layer.addChild(menu); }
public override void onEnter() { base.onEnter(); //add the menu item for back to main menu CCLabelTTF label = CCLabelTTF.labelWithString("MainMenu", "Arial", 20); CCMenuItemLabel pMenuItem = CCMenuItemLabel.itemWithLabel(label, this, new SEL_MenuHandler(MainMenuCallback)); CCMenu pMenu = CCMenu.menuWithItems(pMenuItem); CCSize s = CCDirector.sharedDirector().getWinSize(); pMenu.position = new CCPoint(0.0f, 0.0f); pMenuItem.position = new CCPoint(s.width - 50, 25); 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; }
protected override void AddedToScene() { base.AddedToScene(); var label = new CCLabel("Enable AtlasItem", "fonts/bitmapFontTest3.fnt"); var item1 = new CCMenuItemLabel(label, this.menuCallback2); CCMenuItemFont.FontSize = 28; CCMenuItemFont.FontName = "arial"; var item2 = new CCMenuItemFont("--- Go Back ---", this.menuCallback); // We do not have an HD version of the menuitemsprite so internally CocosSharp tries to convert our // rectangle coordinates passed to work with HD images so the coordinates are off. We will just // modify this here to make sure we have the correct sizes when they are passed. var spriteNormal = new CCSprite(s_MenuItem, new CCRect(0, 23 * 2, 115, 23)); var spriteSelected = new CCSprite(s_MenuItem, new CCRect(0, 23 * 1, 115, 23)); var spriteDisabled = new CCSprite(s_MenuItem, new CCRect(0, 23 * 0, 115, 23)); var item3 = new CCMenuItemImage(spriteNormal, spriteSelected, spriteDisabled, this.menuCallback3); m_disabledItem = item3; m_disabledItem.Enabled = false; var menu = new CCMenu(item1, item2, item3); menu.Position = new CCPoint(0, 0); var s = Layer.VisibleBoundsWorldspace.Size; 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.RepeatForever(jump, jump.Reverse()); var spin1 = new CCRotateBy(3, 360); item1.RepeatForever(spin1); item2.RepeatForever(spin1); item3.RepeatForever(spin1); AddChild(menu); }
public GameLevel() { layerInstance = this; // enable touches #if XBOX || OUYA TouchEnabled = false; GamePadEnabled = true; #else TouchEnabled = true; #endif // enable accelerometer AccelerometerEnabled = false; // ask director for the window size var screenSize = CCDirector.SharedDirector.WinSize; // create and initialize a Label var label = new CCLabelTTF("Game Layer", "MarkerFelt", 22); // position the label on the center of the screen label.Position = CCDirector.SharedDirector.WinSize.Center; // add the label as a child to this Layer AddChild(label); menuStartPosition = new CCPoint(70, screenSize.Height - 24); var gameMenuLabel = new CCLabelTTF("Game Menu", "MarkerFelt", 18); var button1 = new CCMenuItemLabel(gameMenuLabel, ShowMenu); MenuButton = new CCMenu(button1); MenuButton.Position = menuStartPosition; AddChild(MenuButton, 10); openWithMenuInsteadOfGame = false; if (GameData.SharedData.FirstRunEver && openWithMenuInsteadOfGame) { CCLog.Log("First run ever"); Schedule(ShowMenuFromSelector, 2f); GameData.SharedData.FirstRunEver = false; } }
public TestScene() : base(AppDelegate.SharedWindow) #endif { contentLayer = new CCLayer(); AddChild(contentLayer, MENU_LEVEL); //add the menu item for back to main menu var label = new CCLabel("MainMenu", "arial", 20, CCLabelFormat.SpriteFont); pMenuItem = new CCMenuItemLabel(label, MainMenuCallback); pMenu = new CCMenu(pMenuItem); pMenu.Name = "MainMenu"; contentLayer.AddChild(pMenu, MENU_LEVEL); }
public TestController() { // Add close menu closeMenuItem = new CCMenuItemImage(TestResource.s_pPathClose, TestResource.s_pPathClose, CloseCallback); closeMenu = new CCMenu(closeMenuItem); CCMenuItemFont.FontName = "MarkerFelt"; CCMenuItemFont.FontSize = 22; #if !PSM && !WINDOWS_PHONE #if NETFX_CORE && !WINDOWS_UWP versionLabel = new CCLabel("v" + this.GetType().GetAssemblyName().Version.ToString(), "arial", 30); #elif WINDOWS_UWP versionLabel = new CCLabel("v" + this.GetType().GetTypeInfo().Assembly.GetName().Version.ToString(), "arial", 30); #else versionLabel = new CCLabel("v" + this.GetType().Assembly.GetName().Version.ToString(), "fonts/arial", 24, CCLabelFormat.SpriteFont); #endif AddChild(versionLabel, 20000); #endif // Add test list menu testListMenu = new CCMenu(); var i = 0; foreach (var test in testCases.Keys) { var label = new CCLabel(test, "fonts/arial", 24, CCLabelFormat.SpriteFont); var menuItem = new CCMenuItemLabel(label, MenuCallback); testListMenu.AddChild(menuItem, i++ + MENU_ITEM_Z_ORDER); testListMenuItems.Add(menuItem); } LINE_SPACE = (int)(testListMenuItems[0].ContentSize.Height * 1.5f); #if XBOX || OUYA CCSprite sprite = new CCSprite("Images/aButton"); AddChild(sprite, 10001); menuIndicator = sprite; #endif AddChild(testListMenu); AddChild(closeMenu, 1); }
/// <summary> /// show word /// </summary> /// <param name="p_Word">word object</param> private void LoadWord(Word p_Word) { m_y -= 10; //Picture CCTexture2D text2d = Media.PictureManager.GetCCTexture2D(p_Word); CCSprite spritepic = CCSprite.spriteWithTexture(text2d); if (PictureWidth < text2d.ContentSizeInPixels.width) { spritepic.scaleX = PictureWidth / text2d.ContentSizeInPixels.width; } if (PictureHeight < text2d.ContentSizeInPixels.height) { spritepic.scaleY = PictureHeight / text2d.ContentSizeInPixels.height; } spritepic.contentSize.width = PictureWidth; spritepic.contentSize.height = PictureHeight; //word name CCLabelTTF chineseText = CCLabelTTF.labelWithString(p_Word.ChineseName, "ChineseContent", 28); CCMenuItemLabel chineseLabel = CCMenuItemLabel.itemWithLabel(chineseText); CCLabelTTF englishText = CCLabelTTF.labelWithString(p_Word.EnglishName, "EnglishContent", 28); CCMenuItemLabel englishLabel = CCMenuItemLabel.itemWithLabel(englishText); //del button CCLabelTTF delText = CCLabelTTF.labelWithString("删除", "ChineseContent", 28); CCMenuItemLabel delbutton = CCMenuItemLabel.itemWithLabel(delText, this, this.DeleteClick); delbutton.userData = p_Word; CCMenu menu = CCMenu.menuWithItems(delbutton); spritepic.position = new CCPoint(80, m_y - spritepic.contentSize.height / 2); chineseLabel.position = new CCPoint(250, m_y - 40); chineseLabel.Color = new ccColor3B(Color.Black); englishLabel.position = new CCPoint(250, m_y - 80); englishLabel.Color = new ccColor3B(Color.Black); menu.position = new CCPoint(430, m_y - 60); delbutton.Color = new ccColor3B(Color.Black); addChild(spritepic); addChild(chineseLabel); addChild(englishLabel); addChild(menu); m_y -= PictureHeight; m_y -= 10; }
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(); //add the menu item for back to main menu CCLabelTTF label = new CCLabelTTF("MainMenu", "arial", 20); CCMenuItemLabel pMenuItem = new CCMenuItemLabel(label, MainMenuCallback); CCMenu pMenu = new CCMenu(pMenuItem); CCSize s = CCDirector.SharedDirector.WinSize; pMenu.Position = CCPoint.Zero; pMenuItem.Position = new CCPoint(s.Width - 50, 25); AddChild(pMenu, 1); CCApplication.SharedApplication.GamePadDPadUpdate += _GamePadDPadDelegate; CCApplication.SharedApplication.GamePadButtonUpdate += _GamePadButtonDelegate; }
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); }
//--------------------------------------------------------------------------------------------------------- // SetupUI //--------------------------------------------------------------------------------------------------------- // Sets up the game UI //--------------------------------------------------------------------------------------------------------- void SetupUI(CCRect bounds) { shopLabel = new CCLabel("Shop", GOTHIC_44_HD_FNT); shopLabel.AnchorPoint = CCPoint.AnchorMiddle; shopLabel.Scale = 2.0f; var shopItem = new CCMenuItemLabel(shopLabel, Shop); tutorialLabel = new CCLabel("Tutorial", GOTHIC_44_HD_FNT); tutorialLabel.AnchorPoint = CCPoint.AnchorMiddle; tutorialLabel.Scale = 2.0f; var tutorialItem = new CCMenuItemLabel(tutorialLabel, Tutorial); challengesLabel = new CCLabel("Challenges", GOTHIC_44_HD_FNT); challengesLabel.AnchorPoint = CCPoint.AnchorMiddle; challengesLabel.Scale = 2.0f; var challengesItem = new CCMenuItemLabel(challengesLabel, Challenges); freePlayLabel = new CCLabel("Free Play", GOTHIC_44_HD_FNT); freePlayLabel.AnchorPoint = CCPoint.AnchorMiddle; freePlayLabel.Scale = 2.0f; var freePlayItem = new CCMenuItemLabel(freePlayLabel, FreePlay); backLabel = new CCLabel("Back", GOTHIC_44_HD_FNT) { AnchorPoint = CCPoint.AnchorMiddle, Scale = 2.0f, }; var backItem = new CCMenuItemLabel(backLabel, BackToMain); var menu = new CCMenu(tutorialItem, challengesItem, freePlayItem, shopItem, backItem); menu.AnchorPoint = CCPoint.AnchorMiddleBottom; menu.Position = new CCPoint(bounds.Center); menu.AlignItemsVertically(250); AddChild(menu); //TODO: these will have to change to properly calculate when they should unlock challengesItem.Enabled = currentPlayer.BranchProgression [0].BranchState.Equals(CompletionState.completed); freePlayItem.Enabled = !currentPlayer.BranchProgression [13].IsLocked; // this needs to calculate per challenge level shopItem.Enabled = currentPlayer.BranchProgression [0].BranchState.Equals(CompletionState.completed); tutorialItem.Enabled = (currentPlayer.BranchProgression [0].BranchState != CompletionState.completed); }
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 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 Layer4() { CCMenuItemFont.DefaultFontName = "American Typewriter"; CCMenuItemFont.DefaultFontSize = 18; CCMenuItemFont title1 = CCMenuItemFont.ItemWithString ("Sound"); title1.Enabled = false; CCMenuItemFont.DefaultFontName = "Marker Felt"; CCMenuItemFont.DefaultFontSize = 34; NSArray ar = NSArray.FromObjects (CCMenuItemFont.ItemWithString ("On"), CCMenuItemFont.ItemWithString ("Off")); CCMenuItemToggle item1 = new CCMenuItemToggle (ar, menuCallback); CCMenuItemFont.DefaultFontName = "American Typewriter"; CCMenuItemFont.DefaultFontSize = 18; CCMenuItemFont title2 = CCMenuItemFont.ItemWithString ("Music"); title2.Enabled = false; CCMenuItemFont.DefaultFontName = "Marker Felt"; CCMenuItemFont.DefaultFontSize = 34; NSArray ar1 = NSArray.FromObjects (CCMenuItemFont.ItemWithString ("On"), CCMenuItemFont.ItemWithString ("Off")); CCMenuItemToggle item2 = new CCMenuItemToggle (ar1, menuCallback); CCMenuItemFont.DefaultFontName = "American Typewriter"; CCMenuItemFont.DefaultFontSize = 18; CCMenuItemFont title3 = CCMenuItemFont.ItemWithString ("Quality"); title3.Enabled = false; CCMenuItemFont.DefaultFontName = "Marker Felt"; CCMenuItemFont.DefaultFontSize = 34; NSArray ar2 = NSArray.FromNSObjects (CCMenuItemFont.ItemWithString ("High"), CCMenuItemFont.ItemWithString ("Low")); CCMenuItemToggle item3 = new CCMenuItemToggle (ar2, menuCallback); CCMenuItemFont.DefaultFontName = "American Typewriter"; CCMenuItemFont.DefaultFontSize = 18; CCMenuItemFont title4 = CCMenuItemFont.ItemWithString ("Orientation"); title4.Enabled = false; CCMenuItemFont.DefaultFontName = "Marker Felt"; CCMenuItemFont.DefaultFontSize = 34; NSArray ar3 = NSArray.FromNSObjects (CCMenuItemFont.ItemWithString ("Off")); CCMenuItemToggle item4 = new CCMenuItemToggle (ar3, menuCallback); NSObject[] more_items = new NSObject[3]; more_items[0] = CCMenuItemFont.ItemWithString ("33%"); more_items[1] = CCMenuItemFont.ItemWithString ("66%"); more_items[2] = CCMenuItemFont.ItemWithString ("100%"); item4.SubItems.AddObjects (more_items); // you can change the one of the items by doing this item4.SelectedIndex = 2; CCMenuItemFont.DefaultFontName = "Marker Felt"; CCMenuItemFont.DefaultFontSize = 34; CCLabelBMFont label = new CCLabelBMFont("go back", "bitmapFontTest3.fnt"); CCMenuItemLabel back = new CCMenuItemLabel (label, backCallback); CCMenu menu = new CCMenu( title1, title2, item1, item2, title3, title4, item3, item4, back); menu.AlignItemsInColumns (NSNumber.FromUInt32(2), NSNumber.FromUInt32(2), NSNumber.FromUInt32(2), NSNumber.FromUInt32(2), NSNumber.FromUInt32 (1)); this.AddChild (menu); CGSize s = CCDirector.SharedDirector ().WinSize (); menu.Position = new System.Drawing.PointF(s.Width / 2, s.Height / 2); }