Exemplo n.º 1
0
        public static MGMenu menuWithItems(params MGMenuItem[] item)
        {
            MGMenu pRet = new MGMenu();

            if (pRet != null && pRet.initWithItems(item))
            {
                return pRet;
            }

            return null;
        }
Exemplo n.º 2
0
        public TouchLayer()
        {
            Touch = this;
            IsTouchEnable = true;

            MGSprite nShop = MGSprite.MGSpriteWithSpriteFrameName("商店.png");
            MGSprite _nShop = MGSprite.MGSpriteWithSpriteFrameName("商店.png");
            _nShop.Scale = new Vector2(.95f, .95f);
            item = MGMenuItemSprite.itemFromNormalSprite(nShop, _nShop, null, (sender) =>
            {
                var menuitem = sender as MGMenuItemSprite;
                if (menuitem.Tag == 1)
                {
                    MGSprite sShop = MGSprite.MGSpriteWithSpriteFrameName("商店2.png");
                    MGSprite _sShop = MGSprite.MGSpriteWithSpriteFrameName("商店2.png");
                    _sShop.Scale = new Vector2(.95f, .95f);
                    menuitem.NormalImage = sShop;
                    menuitem.SelectedImage = _sShop;
                    if (ShopCallBack1 != null)
                    {
                        ShopCallBack1.Invoke(menu);
                        Istouch = false;
                        MainGameScene.ShardMainGame().CoverLayer.Visible = true;
                        //BugBtn.Visible = true;
                        MainGameLogic.SharedMainGameLogic().GamePause();
                    }
                    menuitem.Tag = 2;
                }
                else
                {
                    MGSprite shop = MGSprite.MGSpriteWithSpriteFrameName("商店.png");
                    MGSprite _shop = MGSprite.MGSpriteWithSpriteFrameName("商店.png");
                    _shop.Scale = new Vector2(.95f, .95f);
                    menuitem.NormalImage = shop;
                    menuitem.SelectedImage = _shop;
                    if (ShopCallBack2 != null)
                    {
                        Istouch = true;
                        ShopCallBack2.Invoke(menu);
                        MainGameScene.ShardMainGame().CoverLayer.Visible = false;
                        _buyBtn.Visible = false;
                        MainGameLogic.SharedMainGameLogic().GameResume();
                    }
                    menuitem.Tag = 1;
                }
            });
            item.Tag = 1;
            menu = MGMenu.menuWithItems(item);
            AddChild(menu);
            menu.Position = new Vector2(40, 500);

            nsp = MGSprite.MGSpriteWithSpriteFrameName("购买1.png");
            _nsp = MGSprite.MGSpriteWithSpriteFrameName("购买1.png");
            _nsp.Scale = new Vector2(.95f, .95f);
            ssp = MGSprite.MGSpriteWithSpriteFrameName("购买2.png");
            _ssp = MGSprite.MGSpriteWithSpriteFrameName("购买2.png");
            _ssp.Scale = new Vector2(.95f, .95f);
            _buymenu = MGMenuItemSprite.itemFromNormalSprite(nsp, _nsp, null, (sender) =>
            {
                if (_paperInfo != null)
                {
                    _paperInfo.Sprite.SetColor(255, 255, 255);
                    if (CardShowLayer.SharedCardShow().Boxs.Count < GameConfig.CardCount)
                    {
                        if (GameConfig.Money >= _paperInfo.Price)
                        {
                            if (GameConfig.ChangeMoney(-_paperInfo.Price))
                            {
                                var card = new CardBox(_paperInfo.Id);
                                card.SetPoint(new Vector2(132 + 7 * 76, 713));
                                CardShowLayer.SharedCardShow().AddChild(card);
                            }
                        }
                    }
                    _paperInfo = null;
                    _buymenu.NormalImage = nsp;
                    _buymenu.NormalImage = _nsp;
                }
            });
            _buyBtn = MGMenu.menuWithItems(_buymenu);
            AddChild(_buyBtn);
            _buyBtn.Position = new Vector2(240, 90);
            _buyBtn.Visible = false;
        }