示例#1
0
        private void CreateQuestionLanguage(CCMenu p_Menu)
        {
            CCLabelTTF label = CCLabelTTF.labelWithString("发音", "ChineseTitle", 28);

            label.Color = new ccColor3B(Color.White);
            CCMenuItemLabel tab = CCMenuItemLabel.itemWithLabel(label);
        }
示例#2
0
        /// <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);
        }
示例#3
0
        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);
        }
示例#4
0
        /// <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;
        }
示例#5
0
        /// <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;
        }
示例#6
0
        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 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);
        }
        /// <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);
        }
示例#9
0
        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);
        }
示例#10
0
        /// <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;
        }
示例#11
0
        /// <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;
        }
示例#12
0
        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));
        }
        /// <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;
        }
示例#14
0
        public LayerGradient()
        {
            CCLayerGradient layer1 = CCLayerGradient.layerWithColor(new ccColor4B(255, 0, 0, 255), new ccColor4B(0, 255, 0, 255), new CCPoint(0.9f, 0.9f));

            addChild(layer1, 0, kTagLayer);

            this.isTouchEnabled = true;

            CCLabelTTF       label1 = CCLabelTTF.labelWithString("Compressed Interpolation: Enabled", "Arial", 26);
            CCLabelTTF       label2 = CCLabelTTF.labelWithString("Compressed Interpolation: Disabled", "Arial", 26);
            CCMenuItemLabel  item1  = CCMenuItemLabel.itemWithLabel(label1);
            CCMenuItemLabel  item2  = CCMenuItemLabel.itemWithLabel(label2);
            CCMenuItemToggle item   = CCMenuItemToggle.itemWithTarget(this, (toggleItem), item1, item2);

            CCMenu menu = CCMenu.menuWithItems(item);

            addChild(menu);
            CCSize s = CCDirector.sharedDirector().getWinSize();

            menu.position = (new CCPoint(s.width / 2, 100));
        }
示例#15
0
        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);
        }
示例#16
0
        public MenuLayer4()
        {
            CCMenuItemFont.FontName = "Arial";
            CCMenuItemFont.FontSize = 18;

            CCMenuItemFont title1 = CCMenuItemFont.itemFromString("Sound");

            title1.Enabled          = false;
            CCMenuItemFont.FontName = "Arial";
            CCMenuItemFont.FontSize = 34;
            CCMenuItemToggle item1 = CCMenuItemToggle.itemWithTarget(this,
                                                                     this.menuCallback,
                                                                     CCMenuItemFont.itemFromString("On"),
                                                                     CCMenuItemFont.itemFromString("Off"));

            CCMenuItemFont.FontName = "Arial";
            CCMenuItemFont.FontSize = 18;
            CCMenuItemFont title2 = CCMenuItemFont.itemFromString("Music");

            title2.Enabled          = false;
            CCMenuItemFont.FontName = "Arial";
            CCMenuItemFont.FontSize = 34;
            CCMenuItemToggle item2 = CCMenuItemToggle.itemWithTarget(this,
                                                                     this.menuCallback,
                                                                     CCMenuItemFont.itemFromString("On"),
                                                                     CCMenuItemFont.itemFromString("Off"));

            CCMenuItemFont.FontName = "Arial";
            CCMenuItemFont.FontSize = 18;
            CCMenuItemFont title3 = CCMenuItemFont.itemFromString("Quality");

            title3.Enabled          = false;
            CCMenuItemFont.FontName = "Arial";
            CCMenuItemFont.FontSize = 34;
            CCMenuItemToggle item3 = CCMenuItemToggle.itemWithTarget(this,
                                                                     this.menuCallback,
                                                                     CCMenuItemFont.itemFromString("High"),
                                                                     CCMenuItemFont.itemFromString("Low"));

            CCMenuItemFont.FontName = "Arial";
            CCMenuItemFont.FontSize = 18;
            CCMenuItemFont title4 = CCMenuItemFont.itemFromString("Orientation");

            title4.Enabled          = false;
            CCMenuItemFont.FontName = "Arial";
            CCMenuItemFont.FontSize = 34;
            CCMenuItemToggle item4 = CCMenuItemToggle.itemWithTarget(this,
                                                                     this.menuCallback,
                                                                     CCMenuItemFont.itemFromString("Off"));

            item4.SubItems.Add(CCMenuItemFont.itemFromString("33%"));
            item4.SubItems.Add(CCMenuItemFont.itemFromString("66%"));
            item4.SubItems.Add(CCMenuItemFont.itemFromString("100%"));

            // you can change the one of the items by doing this
            item4.SelectedIndex = 2;

            CCMenuItemFont.FontName = "Arial";
            CCMenuItemFont.FontSize = 34;

            CCLabelBMFont   label = CCLabelBMFont.labelWithString("go back", "fonts/fnt/bitmapFontTest3");
            CCMenuItemLabel back  = CCMenuItemLabel.itemWithLabel(label, this, this.backCallback);

            CCMenu menu = CCMenu.menuWithItems(
                title1, title2,
                item1, item2,
                title3, title4,
                item3, item4,
                back);           // 9 items.

            menu.alignItemsInColumns(2, 2, 2, 2, 1);

            addChild(menu);
        }
示例#17
0
        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);
        }