Exemplo n.º 1
0
        public static CCMenuItemLabel itemWithLabel(CCNode label, SelectorProtocol target, SEL_MenuHandler selector)
        {
            CCMenuItemLabel cCMenuItemLabel = new CCMenuItemLabel();

            cCMenuItemLabel.initWithLabel(label, target, selector);
            return(cCMenuItemLabel);
        }
Exemplo n.º 2
0
        public static CCMenuItemLabel itemWithLabel(CCNode label)
        {
            CCMenuItemLabel cCMenuItemLabel = new CCMenuItemLabel();

            cCMenuItemLabel.initWithLabel(label, null, null);
            return(cCMenuItemLabel);
        }
Exemplo n.º 3
0
        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;
        }
Exemplo n.º 4
0
        /// <summary>
        /// creates a CCMenuItemLabel with a Label. Target and selector will be nill
        /// </summary>
        public static CCMenuItemLabel itemWithLabel(CCNode label)
        {
            CCMenuItemLabel pRet = new CCMenuItemLabel();

            pRet.initWithLabel(label, null, null);

            return(pRet);
        }
Exemplo n.º 5
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 = 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, 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.TouchEnabled = 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.EffectsVolume = 0.5f;
            SimpleAudioEngine.SharedEngine.BackgroundMusicVolume = 0.5f;
        }
Exemplo n.º 6
0
        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;
        }
Exemplo n.º 7
0
        public LayerGradient()
        {
            CCLayerGradient layer1 = new CCLayerGradient(new CCColor4B(255, 0, 0, 255), new CCColor4B(0, 255, 0, 255), new CCPoint(0.9f, 0.9f));

            AddChild(layer1, 0, kTagLayer);

            this.TouchEnabled = true;

            CCLabelTTF label1 = new CCLabelTTF("Compressed Interpolation: Enabled", "arial", 26);
            CCLabelTTF label2 = new CCLabelTTF("Compressed Interpolation: Disabled", "arial", 26);
            CCMenuItemLabel item1 = new CCMenuItemLabel(label1);
            CCMenuItemLabel item2 = new CCMenuItemLabel(label2);
            CCMenuItemToggle item = new CCMenuItemToggle((toggleItem), item1, item2);

            CCMenu menu = new CCMenu(item);
            AddChild(menu);
            CCSize s = CCDirector.SharedDirector.WinSize;
            menu.Position = (new CCPoint(s.Width / 2, 100));
        }
Exemplo n.º 8
0
        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)(CCSequence.FromActions(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);
        }
Exemplo n.º 9
0
        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 = CCLabelAtlas.Create("0123456789", "Images/fps_Images", 16, 24, '.');
            CCMenuItemLabel item3 = CCMenuItemLabel.Create(labelAtlas, this.menuCallbackDisabled);
            item3.DisabledColor = new CCColor3B(32, 32, 64);
            item3.Color = new CCColor3B(200, 200, 255);

            // Font Item
            CCMenuItemFont item4 = CCMenuItemFont.Create("I toggle enable items", this.menuCallbackEnable);

            item4.FontSizeObj = 20;
            item4.FontNameObj = "arial";

            // Label Item (CCLabelBMFont)
            CCLabelBMFont label = CCLabelBMFont.Create("configuration", "fonts/bitmapFontTest3.fnt");
            CCMenuItemLabel item5 = CCMenuItemLabel.Create(label, this.menuCallbackConfig);

            // Testing issue #500
            item5.Scale = 0.8f;

            // Events
            CCMenuItemFont.FontName = "arial";
            CCMenuItemFont item6 = CCMenuItemFont.Create("Priority Test", menuCallbackPriorityTest);

            // Font Item
            CCMenuItemFont item7 = CCMenuItemFont.Create("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);
        }
Exemplo n.º 10
0
 public static CCMenuItemLabel Create(CCNode label)
 {
     var pRet = new CCMenuItemLabel();
     pRet.InitWithLabel(label, null);
     return pRet;
 }
Exemplo n.º 11
0
 public static CCMenuItemLabel Create(CCNode label, SEL_MenuHandler selector)
 {
     var pRet = new CCMenuItemLabel();
     pRet.InitWithLabel(label, selector);
     return pRet;
 }
Exemplo n.º 12
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);
        }
        /// <summary>
        /// creates a CCMenuItemLabel with a Label. Target and selector will be nill 
        /// </summary>
        public static CCMenuItemLabel itemWithLabel(CCNode label)
        {
            CCMenuItemLabel pRet = new CCMenuItemLabel();
            pRet.initWithLabel(label, null, null);

            return pRet;
        }
        //public override CCPoint anchorPoint
        //{
        //    get
        //    {
        //        return m_pLabel.anchorPoint;
        //    }
        //    set
        //    {
        //        m_pLabel.anchorPoint = value;
        //    }
        //}
        /// <summary>
        /// creates a CCMenuItemLabel with a Label, target and selector
        /// </summary>
        public static CCMenuItemLabel itemWithLabel(CCNode label, SelectorProtocol target, SEL_MenuHandler selector)
        {
            CCMenuItemLabel pRet = new CCMenuItemLabel();
            pRet.initWithLabel(label, target, selector);

            return pRet;
        }
Exemplo n.º 15
0
        public MenuLayer4()
        {
            CCMenuItemFont.FontName = "arial";
            CCMenuItemFont.FontSize = 18;

            CCMenuItemFont title1 = new CCMenuItemFont("Sound");
            title1.Enabled = false;
            CCMenuItemFont.FontName = "arial";
            CCMenuItemFont.FontSize = 34;
            CCMenuItemToggle item1 = new CCMenuItemToggle(this.menuCallback,
                                                                        new CCMenuItemFont("On"),
                                                                        new CCMenuItemFont("Off"));

            CCMenuItemFont.FontName = "arial";
            CCMenuItemFont.FontSize = 18;
            CCMenuItemFont title2 = new CCMenuItemFont("Music");
            title2.Enabled = false;
            CCMenuItemFont.FontName = "arial";
            CCMenuItemFont.FontSize = 34;
            CCMenuItemToggle item2 = new CCMenuItemToggle(this.menuCallback,
                                                                        new CCMenuItemFont("On"),
                                                                        new CCMenuItemFont("Off"));

            CCMenuItemFont.FontName = "arial";
            CCMenuItemFont.FontSize = 18;
            CCMenuItemFont title3 = new CCMenuItemFont("Quality");
            title3.Enabled = false;
            CCMenuItemFont.FontName = "arial";
            CCMenuItemFont.FontSize = 34;
            CCMenuItemToggle item3 = new CCMenuItemToggle(this.menuCallback,
                                                                        new CCMenuItemFont("High"),
                                                                        new CCMenuItemFont("Low"));

            CCMenuItemFont.FontName = "arial";
            CCMenuItemFont.FontSize = 18;
            CCMenuItemFont title4 = new CCMenuItemFont("Orientation");
            title4.Enabled = false;
            CCMenuItemFont.FontName = "arial";
            CCMenuItemFont.FontSize = 34;
            CCMenuItemToggle item4 = new CCMenuItemToggle(this.menuCallback,
                                                                     new CCMenuItemFont("Off"));

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

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

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

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

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

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

            AddChild(menu);
        }
Exemplo n.º 16
0
        public TestController()
        {
            // add close menu
            var pCloseItem = new CCMenuItemImage(TestResource.s_pPathClose, TestResource.s_pPathClose, closeCallback);
            var pMenu = new CCMenu(pCloseItem);
            var s = CCDirector.SharedDirector.WinSize;
            #if !XBOX && !OUYA
            TouchEnabled = true;
            #else
            GamePadEnabled = true;
            KeypadEnabled = true;
            #endif
            #if WINDOWS || MONOMAC
            GamePadEnabled = true;
            #endif

            pMenu.Position = new CCPoint(0.0f, 0.0f);
            pCloseItem.Position = new CCPoint(s.Width - 30, s.Height - 30);
            #if !PSM && !WINDOWS_PHONE
            #if NETFX_CORE
            CCLabelTTF versionLabel = new CCLabelTTF("v" + this.GetType().GetAssemblyName().Version.ToString(), "arial", 12);
            #else
            CCLabelTTF versionLabel = new CCLabelTTF("v" + this.GetType().Assembly.GetName().Version.ToString(), "arial", 12);
            #endif
            versionLabel.Position = new CCPoint(versionLabel.ContentSizeInPixels.Width/2f, s.Height - 18f);
            versionLabel.HorizontalAlignment = CCTextAlignment.CCTextAlignmentLeft;
            AddChild(versionLabel, 20000);
            #endif
            // add menu items for tests
            m_pItemMenu = new CCMenu();
            for (int i = 0; i < (int)(TestCases.TESTS_COUNT); ++i)
            {
                var label = new CCLabelTTF(Tests.g_aTestNames[i], "arial", 24);
                var pMenuItem = new CCMenuItemLabel(label, menuCallback);

                pMenuItem.UserData = i;
                m_pItemMenu.AddChild(pMenuItem, 10000);
            #if XBOX || OUYA
                pMenuItem.Position = new CCPoint(s.Width / 2, -(i + 1) * LINE_SPACE);
            #else
                pMenuItem.Position = new CCPoint(s.Width / 2, (s.Height - (i + 1) * LINE_SPACE));
            #endif
                _Items.Add(pMenuItem);
            }

            m_pItemMenu.ContentSize = new CCSize(s.Width, ((int)TestCases.TESTS_COUNT + 1) * LINE_SPACE);
            #if XBOX || OUYA
            CCSprite sprite = new CCSprite("Images/aButton");
            AddChild(sprite, 10001);
            _menuIndicator = sprite;
            // Center the menu on the first item so that it is
            // in the center of the screen
            _HomePosition = new CCPoint(0f, s.Height / 2f + LINE_SPACE / 2f);
            _LastPosition = new CCPoint(0f, _HomePosition.Y - (_Items.Count - 1) * LINE_SPACE);

            #else
            _HomePosition = s_tCurPos;
            #endif
            m_pItemMenu.Position = _HomePosition;
            AddChild(m_pItemMenu);

            AddChild(pMenu, 1);

            _GamePadDPadDelegate = new CCGamePadDPadDelegate(MyOnGamePadDPadUpdate);
            _GamePadButtonDelegate = new CCGamePadButtonDelegate(MyOnGamePadButtonUpdate);

            // set the first one to have the selection highlight
            _CurrentItemIndex = 0;
            SelectMenuItem();
        }