Пример #1
0
        public MenuLayerPriorityTest()
        {
            // Testing empty menu
            m_pMenu1 = new CCMenu();
            m_pMenu2 = new CCMenu();


            // Menu 1
            CCMenuItemFont item1 = new CCMenuItemFont("Return to Main Menu", menuCallback);
            CCMenuItemFont item2 = new CCMenuItemFont("Disable menu for 5 seconds", disableMenuCallback);


            m_pMenu1.AddChild(item1);
            m_pMenu1.AddChild(item2);

            m_pMenu1.AlignItemsVertically(2);

            AddChild(m_pMenu1);

            // Menu 2
            m_bPriority = true;
            //CCMenuItemFont.setFontSize(48);
            item1 = new CCMenuItemFont("Toggle priority", togglePriorityCallback);
            item1.Scale = 1.5f;
            item1.Color = new CCColor3B(0, 0, 255);
            m_pMenu2.AddChild(item1);
            AddChild(m_pMenu2);
        }
Пример #2
0
		public NodeToWorld3D()
		{
			//
			// This code tests that nodeToParent works OK:
			//  - It tests different anchor Points
			//  - It tests different children anchor points

			parent = new CCNode();
			parent.AnchorPoint = new CCPoint(0.5f, 0.5f);
			AddChild(parent);

			back = new CCSprite(TestResource.s_back3);
			parent.AddChild(back, -10);
			back.AnchorPoint = CCPoint.Zero;


			var item = new CCMenuItemImage(TestResource.s_PlayNormal, TestResource.s_PlaySelect);
			menu = new CCMenu(item);
			menu.AlignItemsVertically();

			back.AddChild(menu);

			item.RepeatForever(CocosNodeTestStaticLibrary.nodeRotate);

			back.RepeatForever(CocosNodeTestStaticLibrary.nodeMove, CocosNodeTestStaticLibrary.nodeMove.Reverse());

			parent.RunAction (CocosNodeTestStaticLibrary.nodeOrbit);
		}
Пример #3
0
        public override void OnEnter()
        {
            base.OnEnter();

            var s = Layer.VisibleBoundsWorldspace.Size;

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

            var pMainItem = new CCMenuItemFont("Back", toMainLayer);
            pMainItem.Position = new CCPoint(s.Width - 50, 25);
            var pMenu = new CCMenu(pMainItem);
            pMenu.Position = new CCPoint(0, 0);

            if (m_bControlMenuVisible)
            {
                var item1 = new CCMenuItemImage("Images/b1", "Images/b2", backCallback);
                var item2 = new CCMenuItemImage("Images/r1", "Images/r2", restartCallback);
                var item3 = new CCMenuItemImage("Images/f1", "Images/f2", nextCallback);
                item1.Position = new CCPoint(s.Width / 2 - 100, 30);
                item2.Position = new CCPoint(s.Width / 2, 30);
                item3.Position = new CCPoint(s.Width / 2 + 100, 30);

                pMenu.AddChild(item1, PerformanceTestScene.kItemTagBasic);
                pMenu.AddChild(item2, PerformanceTestScene.kItemTagBasic);
                pMenu.AddChild(item3, PerformanceTestScene.kItemTagBasic);
            }
            AddChild(pMenu);
        }
Пример #4
0
        private bool InitTableViewTestLayer()
        {

            var winSize = Layer.VisibleBoundsWorldspace.Size;

            var tableView = new CCTableView(this, new CCSize(250, 60));
            tableView.Direction = CCScrollViewDirection.Horizontal;
            tableView.Position = new CCPoint(20, winSize.Height / 2 - 30);
            tableView.Delegate = this;
            this.AddChild(tableView);
            tableView.ReloadData();

            tableView = new CCTableView(this, new CCSize(60, 280));
            tableView.Direction = CCScrollViewDirection.Vertical;
            tableView.Position = new CCPoint(winSize.Width - 150, winSize.Height / 2 - 120);
            tableView.Delegate = this;
            tableView.VerticalFillOrder = CCTableViewVerticalFillOrder.FillTopDown;
            this.AddChild(tableView);
            tableView.ReloadData();

            // Back Menu
            var itemBack = new CCMenuItemFont("Back", toExtensionsMainLayer);
            itemBack.Position = new CCPoint(winSize.Width - 50, 25);
            var menuBack = new CCMenu(itemBack);
            menuBack.Position = CCPoint.Zero;
            AddChild(menuBack);

            return true;
        }
        public override void OnEnter()
        {
            base.OnEnter();

            // Testing empty menu
            menu1 = new CCMenu();
            menu2 = new CCMenu();


            // Menu 1
            var item1 = new CCMenuItemFont("Return to Main Menu", menuCallback);
            var item2 = new CCMenuItemFont("Disable menu for 5 seconds", disableMenuCallback);


            menu1.AddChild(item1);
            menu1.AddChild(item2);

            menu1.AlignItemsVertically(2);

            AddChild(menu1);

            // Menu 2
            priority = true;
            //CCMenuItemFont.setFontSize(48);
            item1 = new CCMenuItemFont("Toggle priority", togglePriorityCallback);
            item1.Scale = 1.5f;
            item1.Color = new CCColor3B(0, 0, 255);
            menu2.AddChild(item1);
            AddChild(menu2);
        }
        public override void OnEnter ()
        {
            base.OnEnter ();

            var origin = Layer.VisibleBoundsWorldspace.Size;

            var label1 = new CCLabel(string.Empty, "debuguncompressed", 0, CCLabelFormat.SpriteFont);

            var texture = label1.TextureAtlas != null ? label1.TextureAtlas.Texture : null;

            if (texture != null) {
                spriteFontNode = new CCSprite (texture);
                spriteFontNode.Scale = 2;
            }
            else
            {
                spriteFontNode = new CCLabel("Texture can not be loaded", "arial", 24, CCLabelFormat.SpriteFont);
            }
            //spriteFontNode.Color = CCColor3B.Magenta;
            spriteFontNode.Position = origin.Center;


            AddChild (spriteFontNode);

            var itemUncompressed = new CCMenuItemLabel(new CCLabel("Uncompressed", "fonts/arial", 24, CCLabelFormat.SpriteFont));
            var itemCompressed = new CCMenuItemLabel(new CCLabel("Compressed", "fonts/arial", 24, CCLabelFormat.SpriteFont));
            itemUncompressed.AnchorPoint = CCPoint.AnchorMiddleLeft;
            itemCompressed.AnchorPoint = CCPoint.AnchorMiddleLeft;
            var mi1 = new CCMenuItemToggle(OnToggle, itemUncompressed, itemCompressed);
            var menu = new CCMenu(mi1);

            AddChild(menu);
            menu.Position = VisibleBoundsWorldspace.Left();
        }
Пример #7
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            CCLabelTtf label = new CCLabelTtf(title(), "arial", 24);

            AddChild(label);
            label.Position = new CCPoint(s.Width / 2, s.Height - 50);

            string subTitle = m_pNotificationLayer.subtitle();

            if (subTitle != null)
            {
                CCLabelTtf l = new CCLabelTtf(subTitle, subtitle(), 16);
                AddChild(l, 1);
                l.Position = new CCPoint(s.Width / 2, s.Height - 80);
            }

            CCMenuItemImage item1 = new CCMenuItemImage("Images/b1.png", "Images/b2.png", backCallback);
            CCMenuItemImage item2 = new CCMenuItemImage("Images/r1.png", "Images/r2.png", restartCallback);
            CCMenuItemImage item3 = new CCMenuItemImage("Images/f1.png", "Images/f2.png", nextCallback);

            CCMenu menu = new CCMenu(item1, item2, item3);

            menu.Position  = new CCPoint(0, 0);
            item1.Position = new CCPoint(s.Width / 2 - 100, 30);
            item2.Position = new CCPoint(s.Width / 2, 30);
            item3.Position = new CCPoint(s.Width / 2 + 100, 30);

            AddChild(menu, 1);
        }
Пример #8
0
		public override void OnEnter()
		{
			base.OnEnter();

			var s = Layer.VisibleBoundsWorldspace.Size;

			var sprite = new CCSprite("Images/grossinis_sister1.png");
			sprite.Position = VisibleBoundsWorldspace.Center;
			AddChild(sprite);
			sprite.RepeatForever(rotateBy);

			// Add a menu item to resume the Scheduled actions.

			CCMenuItemFont.FontSize = 32;
			CCMenuItemFont.FontName = "MarkerFelt";
			var menu = new CCMenu(
				new CCMenuItemFont("Resume", resume)
			);

			menu.AlignItemsVertically(4);
			menu.Position = new CCPoint(s.Width / 2, s.Height / 4);
			AddChild(menu);


			Schedule ();
			Schedule (tick1, 0.5f);
			Schedule (tick2, 1.0f);
			Schedule (pause, 3.0f, 0, 0);
		}
Пример #9
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            var label = new CCLabel(title(), "arial", 26, CCLabelFormat.SpriteFont);
            AddChild(label, 1);
            label.Position = (new CCPoint(s.Width / 2, s.Height - 50));

            string strSubTitle = subtitle();
            if (strSubTitle.Length > 0)
            {
                var l = new CCLabel(strSubTitle, "Thonburi", 16, CCLabelFormat.SpriteFont);
                AddChild(l, 1);
                l.Position = (new CCPoint(s.Width / 2, s.Height - 80));
            }

            CCMenuItemImage item1 = new CCMenuItemImage(TestResource.s_pPathB1, TestResource.s_pPathB2, backCallback);
            CCMenuItemImage item2 = new CCMenuItemImage(TestResource.s_pPathR1, TestResource.s_pPathR2, restartCallback);
            CCMenuItemImage item3 = new CCMenuItemImage(TestResource.s_pPathF1, TestResource.s_pPathF2, nextCallback);

            CCMenu menu = new CCMenu(item1, item2, item3);

            menu.Position = (new CCPoint(0, 0));
            item1.Position = (new CCPoint(s.Width / 2 - 100, 30));
            item2.Position = (new CCPoint(s.Width / 2, 30));
            item3.Position = (new CCPoint(s.Width / 2 + 100, 30));
            AddChild(menu, 1);
        }
Пример #10
0
        public void reset()
        {

            int localtag = 0;
            localtag++;

            // TO TRIGGER THE BUG:
            // remove the itself from parent from an action
            // The menu will be removed, but the instance will be alive
            // and then a new node will be allocated occupying the memory.
            // => CRASH BOOM BANG
            CCNode node = GetChildByTag(localtag - 1);
            CCLog.Log("Menu: %p", node);
            RemoveChild(node, false);
            //	[self removeChildByTag:localtag-1 cleanup:NO];

            CCMenuItem item1 = new CCMenuItemFont("One", menuCallback);
            CCLog.Log("MenuItemFont: %p", item1);
            CCMenuItem item2 = new CCMenuItemFont("Two", menuCallback);
            CCMenu menu = new CCMenu(item1, item2);
            menu.AlignItemsVertically();

            float x = CCRandom.Next() * 50;
            float y = CCRandom.Next() * 50;
            menu.Position = menu.Position + new CCPoint(x, y);
            AddChild(menu, 0, localtag);

            //[self check:self];
        }
Пример #11
0
		public HighScoreLayer (int score): base()
		{
			currentScore = score;


			var batchnode = GetChildByTag ((int)Tags.SpriteManager) as CCSpriteBatchNode;
			var title = new CCSprite(batchnode.Texture,new CCRect(608,192,225,57));
            title.Position=new CCPoint(160,240);
			batchnode.AddChild (title);



			var button1 = new CCMenuItemImage("Images/playAgainButton", "Images/playAgainButton",
                new Action<object>(delegate(object o) {
			 	 Director.ReplaceScene(new CCTransitionFade(.5f, GameLayer.Scene, new CCColor3B(255,255,255)));
                }));
			var button2 = new CCMenuItemImage("Images/changePlayerButton", "Images/changePlayerButton", new Action<object>(delegate (object sender) {
                // do nothing
			}));
			var menu = new CCMenu(button1,button2);
            menu.Position=new CCPoint(160,58);
			menu.AlignItemsVertically(9);

			AddChild (menu);
			

		}
Пример #12
0
        public LabelTTFTest()
        {

            CCMenuItemFont.FontSize = 32;
            CCMenuItemFont.FontName = "MarkerFelt";

            menuLeft = new CCMenu(
                new CCMenuItemFont("Left", setAlignmentLeft),
                new CCMenuItemFont("Center", setAlignmentCenter),
                new CCMenuItemFont("Right", setAlignmentRight)
            );
            menuLeft.AlignItemsVertically(4);

            AddChild(menuLeft);

            menuRight = new CCMenu(
                new CCMenuItemFont("Top", setAlignmentTop),
                new CCMenuItemFont("Middle", setAlignmentMiddle),
                new CCMenuItemFont("Bottom", setAlignmentBottom)
            );
            menuRight.AlignItemsVertically(4);

            AddChild(menuRight);

        }
Пример #13
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            CCLabelTtf label = new CCLabelTtf(title(), "arial", 32);
            AddChild(label);
            label.Position = (new CCPoint(s.Width / 2, s.Height - 50));

            string subTitle = subtitle();
            if (!string.IsNullOrEmpty(subTitle))
            {
                CCLabelTtf l = new CCLabelTtf(subTitle, "arial", 16);
                AddChild(l, 1);
                l.Position = new CCPoint(s.Width / 2, s.Height - 80);
            }

            CCMenuItemImage item1 = new CCMenuItemImage("Images/b1", "Images/b2", backCallback);
            CCMenuItemImage item2 = new CCMenuItemImage("Images/r1", "Images/r2", restartCallback);
            CCMenuItemImage item3 = new CCMenuItemImage("Images/f1", "Images/f2", nextCallback);

            CCMenu menu = new CCMenu(item1, item2, item3);
            menu.Position = new CCPoint(0, 0);
            item1.Position = new CCPoint(s.Width / 2 - 100, 30);
            item2.Position = new CCPoint(s.Width / 2, 30);
            item3.Position = new CCPoint(s.Width / 2 + 100, 30);

            AddChild(menu, 1);
        }
Пример #14
0
        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);

        }
Пример #15
0
        public override void OnEnter ()
        {
            base.OnEnter ();

            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            Box2DView view = Box2DView.viewWithEntryID(m_entryID);
            AddChild(view, 0, kTagBox2DNode);
            view.Scale = 8;
            view.AnchorPoint = new CCPoint(0, 0);
            view.Position = new CCPoint(s.Width / 2, s.Height / 4);

            //#if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE)
            //    CCLabelBMFont* label = new CCLabelBMFont(view.title().c_str(),  "fonts/arial16.fnt");
            //#else    
            CCLabelTtf label = new CCLabelTtf(view.title(), "arial", 18);
            //#endif
            AddChild(label, 1);
            label.Position = new CCPoint(s.Width / 2, s.Height - 30);

            CCMenuItemImage item1 = new CCMenuItemImage("Images/b1", "Images/b2", backCallback);
            CCMenuItemImage item2 = new CCMenuItemImage("Images/r1", "Images/r2", restartCallback);
            CCMenuItemImage item3 = new CCMenuItemImage("Images/f1", "Images/f2", nextCallback);

            CCMenu menu = new CCMenu(item1, item2, item3);

            menu.Position = CCPoint.Zero;
            item1.Position = new CCPoint(s.Width / 2 - 100, 30);
            item2.Position = new CCPoint(s.Width / 2, 30);
            item3.Position = new CCPoint(s.Width / 2 + 100, 30);

            AddChild(menu, 1);
        }
Пример #16
0
        public IntroLayer()
            : base(CCColor4B.Gray)
        {
            titleLabel = new CCLabel("CocosJuce", "fonts/Roboto-Light-72.fnt");
            frequencyLabel = new CCLabel("", "fonts/Roboto-Light-72.fnt");

            onOffSwitchSpriteFrameCache = CCSpriteFrameCache.SharedSpriteFrameCache;
            onOffSwitchSpriteFrameCache.AddSpriteFrames("images/onoffswitch.plist");

            switchOnSprite = new CCSprite("switch_on.png");
            switchOffSprite = new CCSprite("switch_off.png");
            onOffSwitch = new CCMenuItemToggle(SwitchToggle, new CCMenuItem[]
                                                         {
                                                             new CCMenuItemImage(switchOffSprite) { },
                                                             new CCMenuItemImage(switchOnSprite) { },
                                                         });

            menu = new CCMenu(onOffSwitch);

            freqKnobSpriteFrameCache = CCSpriteFrameCache.SharedSpriteFrameCache;
            freqKnobSpriteFrameCache.AddSpriteFrames("images/frequencyknob.plist");

            frequencyKnob = new CCSprite("frequencyknob00.png");

            AddChild(titleLabel);
            AddChild(menu);
            AddChild(frequencyLabel);
            AddChild(frequencyKnob);
        }
Пример #17
0
        private bool InitOrientationTest ()
        {
            bool bRet = false;
            do
            {

                CCSize s = Layer.VisibleBoundsWorldspace.Size;

                var label = new CCLabel(title(), "Arial", 26, CCLabelFormat.SpriteFont);
                AddChild(label, 1);
                label.Position = new CCPoint(s.Width / 2, s.Height - 50);

                string sSubtitle = subtitle();
                if (sSubtitle.Length > 0)
                {
                    var l = new CCLabel(sSubtitle, "Arial", 16, CCLabelFormat.SpriteFont);
                    AddChild(l, 1);
                    l.Position = new CCPoint(s.Width / 2, s.Height - 80);
                }

                CCMenuItemImage item1 = new CCMenuItemImage(TestResource.s_pPathB1, TestResource.s_pPathB2,  BackCallback);
                CCMenuItemImage item2 = new CCMenuItemImage(TestResource.s_pPathR1, TestResource.s_pPathR2,  RestartCallback);
                CCMenuItemImage item3 = new CCMenuItemImage(TestResource.s_pPathF1, TestResource.s_pPathF2,  NextCallback);

                CCMenu menu = new CCMenu(item1, item2, item3);
                menu.Position = s.Center;
                item1.Position = new CCPoint(s.Width / 2 - 100, 30);
                item2.Position = new CCPoint(s.Width / 2, 30);
                item3.Position = new CCPoint(s.Width / 2 + 100, 30);

                bRet = true;
            } while (false);

            return bRet;
        }
Пример #18
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            CCLabelTtf label = new CCLabelTtf(title(), "arial", 40);
            label.AnchorPoint = new CCPoint (0.5f, 0.5f);
            AddChild(label, 1);
            label.Position = (new CCPoint(s.Width / 2, s.Height - 50));

            CCMenuItemImage item1 = new CCMenuItemImage(s_pPathB1, s_pPathB2, backCallback);
            CCMenuItemImage item2 = new CCMenuItemImage(s_pPathR1, s_pPathR2, restartCallback);
            CCMenuItemImage item3 = new CCMenuItemImage(s_pPathF1, s_pPathF2, nextCallback);

            CCMenu menu = new CCMenu(item1, item2, item3);

            float padding = 10.0f;
            float halfRestartWidth = item2.ContentSize.Width / 2.0f;

            menu.Position = (new CCPoint(0, 0));

            // Anchor point of menu items is 0.5, 0.5 by default
            item1.Position = (new CCPoint(s.Width / 2 - item1.ContentSize.Width / 2.0f - halfRestartWidth - padding, item2.ContentSize.Height + padding));
            item2.Position = (new CCPoint(s.Width / 2, item2.ContentSize.Height + padding));
            item3.Position = (new CCPoint(s.Width / 2 + item3.ContentSize.Width / 2.0f + halfRestartWidth + padding, item2.ContentSize.Height + padding));

            AddChild(menu, TestScene.MENU_LEVEL);
        }
Пример #19
0
        public IntervalLayer()
        {
            m_time0 = m_time1 = m_time2 = m_time3 = m_time4 = 0.0f;

            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            // sun
			CCParticleSystem sun = new CCParticleSun(new CCPoint(s.Width / 2, s.Height / 2));
            sun.Texture = CCTextureCache.SharedTextureCache.AddImage("Images/fire");
            sun.Position = (new CCPoint(s.Width - 32, s.Height - 32));

            sun.TotalParticles = 130;
            sun.Life = (0.6f);
            AddChild(sun);

            // timers
            m_label0 = new CCLabelBMFont("0", "fonts/bitmapFontTest4.fnt");
            m_label1 = new CCLabelBMFont("0", "fonts/bitmapFontTest4.fnt");
            m_label2 = new CCLabelBMFont("0", "fonts/bitmapFontTest4.fnt");
            m_label3 = new CCLabelBMFont("0", "fonts/bitmapFontTest4.fnt");
            m_label4 = new CCLabelBMFont("0", "fonts/bitmapFontTest4.fnt");

            Schedule ();

            Schedule(step1);
            Schedule(step2, 0);
            Schedule(step3, 1.0f);
            Schedule(step4, 2.0f);

            m_label0.Position = new CCPoint(s.Width * 1 / 6, s.Height / 2);
            m_label1.Position = new CCPoint(s.Width * 2 / 6, s.Height / 2);
            m_label2.Position = new CCPoint(s.Width * 3 / 6, s.Height / 2);
            m_label3.Position = new CCPoint(s.Width * 4 / 6, s.Height / 2);
            m_label4.Position = new CCPoint(s.Width * 5 / 6, s.Height / 2);

            AddChild(m_label0);
            AddChild(m_label1);
            AddChild(m_label2);
            AddChild(m_label3);
            AddChild(m_label4);

            // Sprite
            CCSprite sprite = new CCSprite(s_pPathGrossini);
            sprite.Position = new CCPoint(40, 50);

            CCJumpBy jump = new CCJumpBy (3, new CCPoint(s.Width - 80, 0), 50, 4);

            AddChild(sprite);
            sprite.RunAction(new CCRepeatForever (
                (CCFiniteTimeAction) (new CCSequence(jump, jump.Reverse())))
                );

            // pause button
            CCMenuItem item1 = new CCMenuItemFont("Pause", onPause);
            CCMenu menu = new CCMenu(item1);
            menu.Position = new CCPoint(s.Width / 2, s.Height - 50);

            AddChild(menu);
        }
Пример #20
0
 /// <summary>
 /// 
 /// </summary>
 public MainMenuLayer()
 {
     Color = CCColor3B.White;
     Opacity = 127;
     Menu = new CCMenu
         (
             new CCMenuItemLabel(new Label("Retour", CCColor3B.Black), ComeBackToGame),
             new CCMenuItemLabel(new Label("Quitter", CCColor3B.Black), LeaveGame)
         );
     Menu.AlignItemsVertically(MENU_ALIGN_PADDING);
 }
Пример #21
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            CCMenuItemFont pMainItem = new CCMenuItemFont("Back", backCallback);
            pMainItem.Position = new CCPoint(s.Width - 50, 25);
            CCMenu pMenu = new CCMenu(pMainItem, null);
            pMenu.Position = new CCPoint(0, 0);
            AddChild(pMenu);
        }
Пример #22
0
        public TestScene()
            : base(AppDelegate.SharedWindow)
        {
            contentLayer = new CCLayer();
            AddChild(contentLayer, MENU_LEVEL);

            //add the menu item for back to main menu
            var label = new CCLabelTtf("MainMenu", "arial", 30);
            pMenuItem = new CCMenuItemLabelTTF(label, MainMenuCallback);

            pMenu = new CCMenu(pMenuItem);

            pMenu.Name = "MainMenu";
            contentLayer.AddChild(pMenu, MENU_LEVEL);
        }
        public virtual void initWithQuantityOfNodes(int nNodes)
        {
            //srand(time());
            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            // Title
            var label = new CCLabel(title(), "arial", 32, CCLabelFormat.SpriteFont);
            AddChild(label, 1);
            label.Position = new CCPoint(s.Width / 2, s.Height - 32);
            label.Color = new CCColor3B(255, 255, 40);

            // Subtitle
            string strSubTitle = subtitle();
            if (strSubTitle.Length > 0)
            {
                var l = new CCLabel(strSubTitle, "arial", 16, CCLabelFormat.SpriteFont);
                AddChild(l, 1);
                l.Position = new CCPoint(s.Width / 2, s.Height - 80);
            }

            lastRenderedCount = 0;
            currentQuantityOfNodes = 0;
            quantityOfNodes = nNodes;

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

            CCMenuItemFont decrease = new CCMenuItemFont(" - ", onDecrease);
            decrease.Color = new CCColor3B(0, 200, 20);
            CCMenuItemFont increase = new CCMenuItemFont(" + ", onIncrease);
            increase.Color = new CCColor3B(0, 200, 20);

            CCMenu menu = new CCMenu(decrease, increase);
            menu.AlignItemsHorizontally();
            menu.Position = new CCPoint(s.Width / 2, s.Height / 2 + 15);
            AddChild(menu, 1);

            var infoLabel = new CCLabel("0 nodes", "arial", 30, CCLabelFormat.SpriteFont);
            infoLabel.Color = new CCColor3B(0, 200, 20);
            infoLabel.Position = new CCPoint(s.Width / 2, s.Height / 2 - 15);
            AddChild(infoLabel, 1, PerformanceNodeChildrenTest.kTagInfoLayer);

            NodeChildrenMenuLayer pMenu = new NodeChildrenMenuLayer(true, PerformanceNodeChildrenTest.TEST_COUNT, PerformanceNodeChildrenTest.s_nCurCase);
            AddChild(pMenu);

            updateQuantityLabel();
            updateQuantityOfNodes();
        }
Пример #24
0
        public SceneTestLayer3() : base(new CCColor4B(0, 0, 255, 255))
        {
            var item0 = new CCMenuItemFont("(3) Touch to pushScene (self)", item0Clicked);
            var item1 = new CCMenuItemFont("(3) Touch to popScene", item1Clicked);
            var item2 = new CCMenuItemFont("(3) Touch to popToRootScene", item2Clicked);
            var item3 = new CCMenuItemFont("(3) Touch to popToSceneStackLevel(2)", item3Clicked);

            CCMenu menu = new CCMenu(item0, item1, item2, item3);
            menu.AlignItemsVertically();

            AddChild(menu);

			CCSprite sprite = new CCSprite(SceneTestScene.grossini) { Tag = SceneTestScene.GROSSINI_TAG};
            AddChild(sprite);
            
        }
Пример #25
0
        public SceneTestLayer1()
        {
            CCMenuItemFont item1 = new CCMenuItemFont("(1) Test PushScene", onPushScene);
            CCMenuItemFont item2 = new CCMenuItemFont("(1) Test PushScene w/Transition", onPushSceneTran);
            CCMenuItemFont item3 = new CCMenuItemFont("(1) Quit", onQuit);
            popMenuItem = new CCMenuItemFont("(1) Test PopScene w/Transition", onPopSceneTran);

            theMenu = new CCMenu(item1, item2, item3, popMenuItem);
            theMenu.AlignItemsVertically();

            AddChild(theMenu);

			CCSprite sprite = new CCSprite(SceneTestScene.grossini) { Tag = SceneTestScene.GROSSINI_TAG };
            AddChild(sprite);
            
        }
Пример #26
0
        public CCControlScene()
		{  
			// Get the screensize
			CCSize screensize = Layer.VisibleBoundsWorldspace.Size;

			var pBackItem = new CCMenuItemFont("Back", toExtensionsMainLayer);
			pBackItem.Position = new CCPoint(screensize.Width - 50, 25);
			var pBackMenu = new CCMenu(pBackItem);
			pBackMenu.Position =  CCPoint.Zero;
			AddChild(pBackMenu, 10);

			// Add the generated background
			var background = new CCSprite("extensions/background");
			background.Position = new CCPoint(screensize.Width / 2, screensize.Height / 2);
			AddChild(background);
    
			// Add the ribbon
			var ribbon = new CCScale9SpriteFile("extensions/ribbon", new CCRect(1, 1, 48, 55));
			ribbon.ContentSize = new CCSize(screensize.Width, 57);
			ribbon.Position = new CCPoint(screensize.Width / 2.0f, screensize.Height - ribbon.ContentSize.Height / 2.0f);
			AddChild(ribbon);
    
			// Add the title
			setSceneTitleLabel(new CCLabelTtf(" ", "Arial", 12));
			m_pSceneTitleLabel.Position = new CCPoint(screensize.Width / 2, screensize.Height - m_pSceneTitleLabel.ContentSize.Height / 2 - 5);
			AddChild(m_pSceneTitleLabel, 1);

            // Add the subtitle
            setSceneSubtitleLabel(new CCLabelTtf(" ", "Arial", 12));
		    m_pSceneSubtitleLabel.Position = new CCPoint(screensize.Width / 2,
		                                                 screensize.Height - m_pSceneTitleLabel.ContentSize.Height -
		                                                 m_pSceneSubtitleLabel.ContentSize.Height / 2 - 10);
            AddChild(m_pSceneSubtitleLabel, 1);
    
			// Add the menu
			var item1 = new CCMenuItemImage("Images/b1", "Images/b2", previousCallback);
			var item2 = new CCMenuItemImage("Images/r1", "Images/r2", restartCallback);
			var item3 = new CCMenuItemImage("Images/f1", "Images/f2", nextCallback);
    
			var menu = new CCMenu(item1, item3, item2);
			menu.Position = CCPoint.Zero;
			item1.Position = new CCPoint(screensize.Width / 2 - 100, 37);
			item2.Position = new CCPoint(screensize.Width / 2, 35);
			item3.Position = new CCPoint(screensize.Width / 2 + 100, 37);
    
			AddChild(menu, 1);
		}
Пример #27
0
        protected override void AddedToScene() {
            base.AddedToScene();

            var _menuPos = new CCPoint(Settings.ScreenSize.Center);

            CCLabelTtf labelStartGame = GetMenuLabel("Start Game");
            CCMenuItem itemStart = new CCMenuItemLabelTTF(labelStartGame, StartGame);

            CCLabelTtf labelExit = GetMenuLabel("Exit Game");
            CCMenuItem itemExit = new CCMenuItemLabelTTF(labelExit, ExitGame);


            MainMenu = new CCMenu(itemStart, itemExit) {Position = _menuPos};
            MainMenu.AlignItemsVertically(15);

            AddChild(MainMenu);
        }
Пример #28
0
        public SceneTestLayer2()
        {
            m_timeCounter = 0;

            CCMenuItemFont item1 = new CCMenuItemFont("(2) replaceScene", onReplaceScene);
            CCMenuItemFont item2 = new CCMenuItemFont("(2) replaceScene w/transition", onReplaceSceneTran);
            CCMenuItemFont item3 = new CCMenuItemFont("(2) Go Back", onGoBack);
            popMenuItem = new CCMenuItemFont("(2) Test popScene w/transition", onPopSceneTran);

			theMenu = new CCMenu(item1, item2, item3, popMenuItem);
            theMenu.AlignItemsVertically();

            AddChild(theMenu);

			CCSprite sprite = new CCSprite(SceneTestScene.grossini) { Tag = SceneTestScene.GROSSINI_TAG };
            AddChild(sprite);
        }
Пример #29
0
        public CocosDenshionTest()
        {
            testMenu = null;
            beginPos = new CCPoint(0,0);
            soundId = 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"
            };

            testMenu = new CCMenu(null);
            testMenuItems = new List<CCMenuItem>();

            for(int i=0; i < testItems.Count(); ++i)
            {
                CCLabelTtf label = new CCLabelTtf(testItems[i], "arial", 24);
                CCMenuItemLabelTTF menuItem = new CCMenuItemLabelTTF(label, MenuCallback);
                testMenu.AddChild(menuItem, i + 10000);
                testMenuItems.Add(menuItem);
            }

            AddChild(testMenu);

            // 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;

            Camera = AppDelegate.SharedCamera;
        }
Пример #30
0
        protected override void AddedToScene()
        {
            base.AddedToScene();

            var label = new CCLabelBMFont("Enable AtlasItem", "fonts/bitmapFontTest3.fnt");
            var item1 = new CCMenuItemLabelBMFont(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);
        }
Пример #31
0
        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
            versionLabel = new CCLabel("v" + this.GetType().GetAssemblyName().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);
        }