예제 #1
0
        public override bool Init()
        {
            if (base.Init())
            {
                // ask director the the window size
                CCSize size = CCDirector.SharedDirector.WinSize;

                QuestionContainerSprite question = new QuestionContainerSprite();
                QuestionContainerSprite question2 = new QuestionContainerSprite();
                question.Init();
                question2.Init();

                //		[question setContentSize:CGSizeMake(50,50)];
                //		[question2 setContentSize:CGSizeMake(50,50)];

                CCMenuItemSprite sprite = new CCMenuItemSprite(question2, question, this, selectAnswer);
                CCLayerColor layer = new CCLayerColor(new CCColor4B(0, 0, 255, 255), 100, 100);

                CCLayerColor layer2 = new CCLayerColor(new CCColor4B(255, 0, 0, 255), 100, 100);
                CCMenuItemSprite sprite2 = new CCMenuItemSprite(layer, layer2, this, selectAnswer);
                CCMenu menu = new CCMenu(sprite, sprite2, null);
                menu.AlignItemsVerticallyWithPadding(100);
                menu.Position = new CCPoint(size.Width / 2, size.Height / 2);

                // add the label as a child to this Layer
                AddChild(menu);

                return true;
            }
            return false;
        }
예제 #2
0
        public static CCMenuItemSprite itemFromNormalSprite(CCNode normalSprite, CCNode selectedSprite, CCNode disabledSprite, SelectorProtocol target, SEL_MenuHandler selector)
        {
            CCMenuItemSprite cCMenuItemSprite = new CCMenuItemSprite();

            cCMenuItemSprite.initFromNormalSprite(normalSprite, selectedSprite, disabledSprite, target, selector);
            return(cCMenuItemSprite);
        }
        /// <summary>
        /// creates a menu item with a normal,selected  and disabled image with target/selector
        /// </summary>
        /// <param name="normalSprite"></param>
        /// <param name="selectedSprite"></param>
        /// <param name="disabledSprite"></param>
        /// <param name="target"></param>
        /// <param name="selector"></param>
        /// <returns></returns>
        public static CCMenuItemSprite itemFromNormalSprite(CCNode normalSprite, CCNode selectedSprite, CCNode disabledSprite,
                                                            SelectorProtocol target, SEL_MenuHandler selector)
        {
            CCMenuItemSprite pRet = new CCMenuItemSprite();

            pRet.initFromNormalSprite(normalSprite, selectedSprite, disabledSprite, target, selector);
            //pRet->autorelease();
            return(pRet);
        }
예제 #4
0
        public MenuLayer3()
        {
            CCMenuItemFont.FontName = "arial";
            CCMenuItemFont.FontSize = 28;

            CCLabelBMFont label = CCLabelBMFont.Create("Enable AtlasItem", "fonts/bitmapFontTest3.fnt");
            CCMenuItemLabel item1 = CCMenuItemLabel.Create(label, this.menuCallback2);
            CCMenuItemFont item2 = CCMenuItemFont.Create("--- 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);
        }
예제 #5
0
 /// <summary>
 /// creates a menu item with a normal,selected  and disabled image with target/selector
 /// </summary>
 /// <param name="normalSprite"></param>
 /// <param name="selectedSprite"></param>
 /// <param name="disabledSprite"></param>
 /// <param name="target"></param>
 /// <param name="selector"></param>
 /// <returns></returns>
 public static CCMenuItemSprite itemFromNormalSprite(CCNode normalSprite, CCNode selectedSprite, CCNode disabledSprite,
                                                 SelectorProtocol target, SEL_MenuHandler selector)
 {
     CCMenuItemSprite pRet = new CCMenuItemSprite();
     pRet.initFromNormalSprite(normalSprite, selectedSprite, disabledSprite, target, selector);
     //pRet->autorelease();
     return pRet;
 }
예제 #6
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);
        }
예제 #7
0
 public static CCMenuItemSprite itemFromNormalSprite(CCNode normalSprite, CCNode selectedSprite, SelectorProtocol target, SEL_MenuHandler selector)
 {
     return(CCMenuItemSprite.itemFromNormalSprite(normalSprite, selectedSprite, null, target, selector));
 }
예제 #8
0
 public static CCMenuItemSprite itemFromNormalSprite(CCNode normalSprite, CCNode selectedSprite)
 {
     return(CCMenuItemSprite.itemFromNormalSprite(normalSprite, selectedSprite, null, null, null));
 }