Esempio n. 1
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)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), 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;
        }
Esempio n. 2
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, 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;
        }
Esempio n. 3
0
		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;
            }

        }
Esempio n. 4
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;
        }
Esempio n. 5
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));
        }
Esempio n. 6
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);
        }
Esempio n. 7
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 = CCPoint.Zero;
            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();
        }
Esempio n. 8
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);
        }
Esempio 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 = 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);
        }