コード例 #1
0
        public LabelsEmpty()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            // CCLabelBMFont
            CCLabelBMFont label1 = new CCLabelBMFont("", "fonts/bitmapFontTest3.fnt");

            AddChild(label1, 0, (int)TagSprite.kTagBitmapAtlas1);
            label1.Position = new CCPoint(s.Width / 2, s.Height - 100);

            // CCLabelTTF
            CCLabelTTF label2 = new CCLabelTTF("", "arial", 24);

            AddChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2);
            label2.Position = new CCPoint(s.Width / 2, s.Height / 2);

            // CCLabelAtlas
            CCLabelAtlas label3 = new CCLabelAtlas("", "fonts/tuffy_bold_italic-charmap", 48, 64, ' ');

            AddChild(label3, 0, (int)TagSprite.kTagBitmapAtlas3);
            label3.Position = new CCPoint(s.Width / 2, 0 + 100);

            base.Schedule(updateStrings, 1.0f);

            setEmpty = false;
        }
コード例 #2
0
        public LabelsEmpty()
        {
            CCSize s = CCDirector.sharedDirector().getWinSize();

            // CCLabelBMFont
            CCLabelBMFont label1 = CCLabelBMFont.labelWithString("", "fonts/fnt/bitmapFontTest3");

            addChild(label1, 0, (int)TagSprite.kTagBitmapAtlas1);
            label1.position = new CCPoint(s.width / 2, s.height - 100);

            // CCLabelTTF
            CCLabelTTF label2 = CCLabelTTF.labelWithString("", "Arial", 24);

            addChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2);
            label2.position = new CCPoint(s.width / 2, s.height / 2);

            // CCLabelAtlas
            CCLabelAtlas label3 = CCLabelAtlas.labelWithString("", "fonts/fnt/images/tuffy_bold_italic-charmap", 48, 64, ' ');

            addChild(label3, 0, (int)TagSprite.kTagBitmapAtlas3);
            label3.position = new CCPoint(s.width / 2, 0 + 100);

            base.schedule(updateStrings, 1.0f);

            setEmpty = false;
        }
コード例 #3
0
        public LabelAtlasColorTest()
        {
            CCLabelAtlas label1 = new CCLabelAtlas("123 Test", "fonts/tuffy_bold_italic-charmap", 48, 64, ' ');

            AddChild(label1, 0, (int)TagSprite.kTagSprite1);
            label1.Position = new CCPoint(10, 100);
            label1.Opacity  = 200;

            CCLabelAtlas label2 = new CCLabelAtlas("0123456789", "fonts/tuffy_bold_italic-charmap", 48, 64, ' ');

            AddChild(label2, 0, (int)TagSprite.kTagSprite2);
            label2.Position = new CCPoint(10, 200);
            label2.Color    = ccRED;

            CCActionInterval   fade    = new CCFadeOut(1.0f);
            CCFiniteTimeAction fade_in = fade.Reverse();
            CCFiniteTimeAction seq     = CCSequence.FromActions(fade, fade_in);
            CCAction           repeat  = new CCRepeatForever((CCActionInterval)seq);

            label2.RunAction(repeat);

            m_time = 0;

            Schedule(step); //:@selector(step:)];
        }
コード例 #4
0
        public LabelAtlasColorTest()
        {
            CCLabelAtlas label1 = CCLabelAtlas.labelWithString("123 Test", "fonts/fnt/images/tuffy_bold_italic-charmap", 48, 64, ' ');

            addChild(label1, 0, (int)TagSprite.kTagSprite1);
            label1.position = new CCPoint(10, 100);
            label1.Opacity  = 200;

            CCLabelAtlas label2 = CCLabelAtlas.labelWithString("0123456789", "fonts/fnt/images/tuffy_bold_italic-charmap", 48, 64, ' ');

            addChild(label2, 0, (int)TagSprite.kTagSprite2);
            label2.position = new CCPoint(10, 200);
            label2.Color    = ccRED;

            CCActionInterval   fade    = CCFadeOut.actionWithDuration(1.0f);
            CCFiniteTimeAction fade_in = fade.reverse();
            CCFiniteTimeAction seq     = CCSequence.actions(fade, fade_in);
            CCAction           repeat  = CCRepeatForever.actionWithAction((CCActionInterval)seq);

            label2.runAction(repeat);

            m_time = 0;

            schedule(step); //:@selector(step:)];
        }
コード例 #5
0
        public ParticleDemo()
        {
            initWithColor(ccTypes.ccc4(127, 127, 127, 255));

            m_emitter = null;

            isTouchEnabled = true;

            CCSize     s     = CCDirector.sharedDirector().getWinSize();
            CCLabelTTF label = CCLabelTTF.labelWithString(title(), "Arial", 28);

            addChild(label, 100, 1000);
            label.position = new CCPoint(s.width / 2, s.height - 50);

            CCLabelTTF tapScreen = CCLabelTTF.labelWithString("(Tap the Screen)", "Arial", 20);

            tapScreen.position = new CCPoint(s.width / 2, s.height - 80);
            addChild(tapScreen, 100);

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

            CCMenuItemToggle item4 = CCMenuItemToggle.itemWithTarget(this,
                                                                     new SEL_MenuHandler(toggleCallback),
                                                                     CCMenuItemFont.itemFromString("Free Movement"),
                                                                     CCMenuItemFont.itemFromString("Relative Movement"),
                                                                     CCMenuItemFont.itemFromString("Grouped Movement"));

            CCMenu menu = CCMenu.menuWithItems(item1, item2, item3, item4);

            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);
            item4.position    = new CCPoint(0, 100);
            item4.anchorPoint = new CCPoint(0, 0);

            addChild(menu, 100);

            CCLabelAtlas labelAtlas = CCLabelAtlas.labelWithString("0000", "fonts/fnt/images/fps_images", 16, 24, '.');

            addChild(labelAtlas, 100, ParticleTestScene.kTagLabelAtlas);
            labelAtlas.position = new CCPoint(s.width - 66, 50);

            // moving background
            m_background = CCSprite.spriteWithFile(TestResource.s_back3);
            addChild(m_background, 5);
            m_background.position = new CCPoint(s.width / 2 - 120, s.height - 240);

            CCActionInterval   move      = CCMoveBy.actionWithDuration(4, new CCPoint(300, 0));
            CCFiniteTimeAction move_back = move.reverse();
            CCFiniteTimeAction seq       = CCSequence.actions(move, move_back);

            m_background.runAction(CCRepeatForever.actionWithAction((CCActionInterval)seq));


            schedule(new SEL_SCHEDULE(step));
        }
コード例 #6
0
        public bool initFromString(string value, string charMapFile, int itemWidth, int itemHeight, char startCharMap, SelectorProtocol target, SEL_MenuHandler selector)
        {
            CCLabelAtlas cCLabelAtla = new CCLabelAtlas();

            cCLabelAtla.initWithString(value, charMapFile, itemWidth, itemHeight, startCharMap);
            base.initWithLabel(cCLabelAtla, target, selector);
            return(true);
        }
コード例 #7
0
 /// <summary>
 /// initializes a menu item from a string and atlas with a target/selector
 /// </summary>
 public bool InitFromString(string value, string charMapFile, int itemWidth, int itemHeight, char startCharMap, SelectorProtocol target,
                            SEL_MenuHandler selector)
 {
     // CCAssert( value != NULL && strlen(value) != 0, "value length must be greater than 0");
     var label = new CCLabelAtlas(value, charMapFile, itemWidth, itemHeight, startCharMap);
     base.InitWithLabel(label, selector);
     return true;
 }
コード例 #8
0
        public LabelAtlasHD()
        {
            // CCLabelBMFont
            label1             = new CCLabelAtlas("TESTING RETINA DISPLAY", "fonts/larabie-16", 10, 20, 'A');
            label1.AnchorPoint = CCPoint.AnchorMiddle;

            AddChild(label1);
        }
コード例 #9
0
        public void step(float dt)
        {
            CCLabelAtlas     atlas   = (CCLabelAtlas)GetChildByTag(PerformanceParticleTest.kTagLabelAtlas);
            CCParticleSystem emitter = (CCParticleSystem)GetChildByTag(PerformanceParticleTest.kTagParticleSystem);

            var str = string.Format("{0:0000}", emitter.ParticleCount);

            atlas.Text = (str);
        }
コード例 #10
0
        /// <summary>
        /// initializes a menu item from a string and atlas with a target/selector
        /// </summary>
        public bool InitFromString(string value, string charMapFile, int itemWidth, int itemHeight, char startCharMap, SelectorProtocol target,
                                   SEL_MenuHandler selector)
        {
            // CCAssert( value != NULL && strlen(value) != 0, "value length must be greater than 0");
            var label = new CCLabelAtlas(value, charMapFile, itemWidth, itemHeight, startCharMap);

            base.InitWithLabel(label, selector);
            return(true);
        }
コード例 #11
0
        public LabelAtlasHD()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            // CCLabelBMFont
            CCLabelAtlas label1 = new CCLabelAtlas("TESTING RETINA DISPLAY", "fonts/larabie-16", 10, 20, 'A');

            label1.AnchorPoint = new CCPoint(0.5f, 0.5f);

            AddChild(label1);
            label1.Position = new CCPoint(s.Width / 2, s.Height / 2);
        }
コード例 #12
0
 /// <summary>
 /// initializes a menu item from a string and atlas with a target/selector
 /// </summary>
 public bool initFromString(string value, string charMapFile, int itemWidth, int itemHeight, char startCharMap, SelectorProtocol target, SEL_MenuHandler selector)
 {
     // CCAssert( value != NULL && strlen(value) != 0, "value length must be greater than 0");
     CCLabelAtlas label = new CCLabelAtlas();
     label.initWithString(value, charMapFile, itemWidth, itemHeight, startCharMap);
     //label->autorelease();
     if (base.initWithLabel(label, target, selector))
     {
         // do something ?
     }
     return true;
 }
コード例 #13
0
        public void step(float dt)
        {
            CCLabelAtlas     atlas   = (CCLabelAtlas)getChildByTag(PerformanceParticleTest.kTagLabelAtlas);
            CCParticleSystem emitter = (CCParticleSystem)getChildByTag(PerformanceParticleTest.kTagParticleSystem);

            //char str[10] = {0};
            string str;

            //sprintf(str, "%4d", emitter->getParticleCount());
            str = string.Format("{0:D4}", emitter.ParticleCount);
            atlas.setString(str);
        }
コード例 #14
0
        public LabelAtlasHD()
        {
            CCSize s = CCDirector.sharedDirector().getWinSize();

            // CCLabelBMFont
            CCLabelAtlas label1 = CCLabelAtlas.labelWithString("TESTING RETINA DISPLAY", "fonts/fnt/images/larabie-16", 10, 20, 'A');

            label1.anchorPoint = new CCPoint(0.5f, 0.5f);

            addChild(label1);
            label1.position = new CCPoint(s.width / 2, s.height / 2);
        }
コード例 #15
0
        /// <summary>
        /// initializes a menu item from a string and atlas with a target/selector
        /// </summary>
        public bool initFromString(string value, string charMapFile, int itemWidth, int itemHeight, char startCharMap, SelectorProtocol target, SEL_MenuHandler selector)
        {
            // CCAssert( value != NULL && strlen(value) != 0, "value length must be greater than 0");
            CCLabelAtlas label = new CCLabelAtlas();

            label.initWithString(value, charMapFile, itemWidth, itemHeight, startCharMap);
            //label->autorelease();
            if (base.initWithLabel(label, target, selector))
            {
                // do something ?
            }
            return(true);
        }
コード例 #16
0
        public void step(float dt)
        {
            if (m_emitter != null)
            {
                CCLabelAtlas atlas = (CCLabelAtlas)getChildByTag(ParticleTestScene.kTagLabelAtlas);

                //char str[5] = {0};
                //sprintf(str, "%04d", m_emitter.getParticleCount());
                //atlas.setString(str);
                string str = string.Format("{0}", m_emitter.ParticleCount);
                atlas.setString(str);
            }
        }
コード例 #17
0
        public LabelsEmpty()
        {
            // CCLabelBMFont
            label1 = new CCLabelBMFont("", "fonts/bitmapFontTest3.fnt");
            AddChild(label1, 0, (int)TagSprite.kTagBitmapAtlas1);

            // CCLabelTTF
            label2 = new CCLabelTtf("", "arial", 24);
            AddChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2);

            // CCLabelAtlas
            label3 = new CCLabelAtlas("", "fonts/tuffy_bold_italic-charmap", 48, 64, ' ');
            AddChild(label3, 0, (int)TagSprite.kTagBitmapAtlas3);

            base.Schedule(updateStrings, 1.0f);

            setEmpty = false;
        }
コード例 #18
0
        public LabelAtlasTest()
        {
            m_time = 0;

            var label1 = new CCLabelAtlas("123 Test", "fonts/tuffy_bold_italic-charmap", 48, 64, ' ');

            AddChild(label1, 0, (int)TagSprite.kTagSprite1);
            label1.Position = new CCPoint(10, 100);
            label1.Opacity  = 200;

            var label2 = new CCLabelAtlas("0123456789", "fonts/tuffy_bold_italic-charmap", 48, 64, ' ');

            AddChild(label2, 0, (int)TagSprite.kTagSprite2);
            label2.Position = new CCPoint(10, 200);
            label2.Opacity  = 32;

            Schedule(step);
        }
コード例 #19
0
        public LabelAtlasTest()
        {
            m_time = 0;

            CCLabelAtlas label1 = CCLabelAtlas.labelWithString("123 Test", "fonts/fnt/images/tuffy_bold_italic-charmap", 48, 64, ' ');

            addChild(label1, 0, (int)TagSprite.kTagSprite1);
            label1.position = new CCPoint(10, 100);
            label1.Opacity  = 200;

            CCLabelAtlas label2 = CCLabelAtlas.labelWithString("0123456789", "fonts/fnt/images/tuffy_bold_italic-charmap", 48, 64, ' ');

            addChild(label2, 0, (int)TagSprite.kTagSprite2);
            label2.position = new CCPoint(10, 200);
            label2.Opacity  = 32;

            schedule(step);
        }
コード例 #20
0
        public virtual void step(float dt)
        {
            m_time += dt;
            //char string[12] = {0};
            string stepstring;

            //sprintf(string, "%2.2f Test", m_time);
            stepstring = string.Format("{0,2:f2} Test", m_time);
            //std::string string = std::string::stringWithFormat("%2.2f Test", m_time);
            CCLabelAtlas label1 = (CCLabelAtlas)GetChildByTag((int)TagSprite.kTagSprite1);

            label1.Label = (stepstring);

            CCLabelAtlas label2 = (CCLabelAtlas)GetChildByTag((int)TagSprite.kTagSprite2);

            //sprintf(string, "%d", (int)m_time);
            stepstring   = string.Format("{0:D1}", (int)m_time);
            label2.Label = (stepstring);
        }
コード例 #21
0
        public virtual void step(float dt)
        {
            m_time += dt;
            //char string[12] = {0};
            string Stepstring;

            //sprintf(Stepstring, "%2.2f Test", m_time);
            Stepstring = string.Format("{0,2:f2} Test", m_time);
            //Stepstring.format("%2.2f Test", m_time);

            CCLabelAtlas label1 = (CCLabelAtlas)GetChildByTag((int)TagSprite.kTagSprite1);

            label1.Text = (Stepstring);

            CCLabelAtlas label2 = (CCLabelAtlas)GetChildByTag((int)TagSprite.kTagSprite2);

            //sprintf(Stepstring, "%d", (int)m_time);
            Stepstring  = m_time.ToString();
            Stepstring  = string.Format("{0:d}", (int)m_time);
            label2.Text = (Stepstring);
        }
コード例 #22
0
        public void updateStrings(float dt)
        {
            CCLabelBMFont label1 = (CCLabelBMFont)GetChildByTag((int)TagSprite.kTagBitmapAtlas1);
            CCLabelTTF    label2 = (CCLabelTTF)GetChildByTag((int)TagSprite.kTagBitmapAtlas2);
            CCLabelAtlas  label3 = (CCLabelAtlas)GetChildByTag((int)TagSprite.kTagBitmapAtlas3);

            if (!setEmpty)
            {
                label1.Text = ("not empty");
                label2.Text = ("not empty");
                label3.Text = ("hi");

                setEmpty = true;
            }
            else
            {
                label1.Text = ("");
                label2.Text = ("");
                label3.Text = ("");

                setEmpty = false;
            }
        }
コード例 #23
0
        public MenuLayer1()
        {
            // Register Touch Event
            touchListener = new CCEventListenerTouchOneByOne();
            touchListener.IsSwallowTouches = true;

            touchListener.OnTouchBegan     = onTouchBegan;
            touchListener.OnTouchMoved     = onTouchMoved;
            touchListener.OnTouchEnded     = onTouchEnded;
            touchListener.OnTouchCancelled = onTouchCancelled;

            AddEventListener(touchListener, 1);

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


            var item1 = new CCMenuItemImage(spriteNormal, spriteSelected, spriteDisabled, this.menuCallback);

            // Image Item
            var item2 = new CCMenuItemImage(s_SendScore, s_PressSendScore, this.menuCallback2);

            // Label Item (LabelAtlas)
            var labelAtlas = new CCLabelAtlas("0123456789", "Images/fps_Images.png", 12, 32, '.');
            var item3      = new CCMenuItemLabelAtlas(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", (sender) =>
            {
                disabledItem.Enabled = !disabledItem.Enabled;
            });

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


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

            CCMenuItemFont.FontSize = 30;
            // Events
            CCMenuItemFont item6 = new CCMenuItemFont("Priority Test", menuCallbackPriorityTest);

            // Font Item
            CCMenuItemFont item7 = new CCMenuItemFont("Quit", this.onQuit);

            item7.RepeatForever(color_action, color_action.Reverse());

            menu = new CCMenu(item1, item2, item3, item4, item5, item6, item7);
            menu.AlignItemsVertically();

            disabledItem         = item3;
            disabledItem.Enabled = false;

            AddChild(menu);
            menu.Scale = 0;
            menu.RunAction(new CCScaleTo(1, 1));
        }
コード例 #24
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);
        }
コード例 #25
0
ファイル: MenuLayer1.cs プロジェクト: zhuruvl/CocosSharp
        protected override void AddedToScene()
        {
            base.AddedToScene();

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


            var item1 = new CCMenuItemImage(spriteNormal, spriteSelected, spriteDisabled, this.menuCallback);

            // Image Item
            var item2 = new CCMenuItemImage(s_SendScore, s_PressSendScore, this.menuCallback2);

            // Label Item (LabelAtlas)
            var labelAtlas = new CCLabelAtlas("0123456789", "Images/fps_Images.png", 12, 32, '.');
            var item3      = new CCMenuItemLabelAtlas(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", (sender) =>
            {
                disabledItem.Enabled = !disabledItem.Enabled;
            });

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


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

            CCMenuItemFont.FontSize = 30;
            // Events
            CCMenuItemFont item6 = new CCMenuItemFont("Priority Test", menuCallbackPriorityTest);

            // Font Item
            CCMenuItemFont item7 = new CCMenuItemFont("Quit", this.onQuit);

            item7.RepeatForever(color_action, color_action.Reverse());

            menu = new CCMenu(item1, item2, item3, item4, item5, item6, item7);
            menu.AlignItemsVertically();

            disabledItem         = item3;
            disabledItem.Enabled = false;

            AddChild(menu);
            menu.Scale = 0;
            menu.RunAction(new CCScaleTo(1, 1));

            // elastic effect
            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            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++;
                }
            }
        }
コード例 #26
0
        public virtual void initWithSubTest(int asubtest, int particles)
        {
            //srandom(0);

            subtestNumber = asubtest;
            CCSize s = CCDirector.sharedDirector().getWinSize();

            lastRenderedCount = 0;
            quantityParticles = particles;

            CCMenuItemFont.FontSize = 65;
            CCMenuItemFont decrease = CCMenuItemFont.itemFromString(" - ", this, onDecrease);

            decrease.Color = new ccColor3B(0, 200, 20);
            CCMenuItemFont increase = CCMenuItemFont.itemFromString(" + ", this, onIncrease);

            increase.Color = new ccColor3B(0, 200, 20);

            CCMenu menu = CCMenu.menuWithItems(decrease, increase);

            menu.alignItemsHorizontally();
            menu.position = new CCPoint(s.width / 2, s.height / 2 + 15);
            addChild(menu, 1);

            CCLabelTTF infoLabel = CCLabelTTF.labelWithString("0 nodes", "Marker Felt", 30);

            infoLabel.Color    = new ccColor3B(0, 200, 20);
            infoLabel.position = new CCPoint(s.width / 2, s.height - 90);
            addChild(infoLabel, 1, PerformanceParticleTest.kTagInfoLayer);

            // particles on stage
            CCLabelAtlas labelAtlas = CCLabelAtlas.labelWithString("0000", "Images/fps_images", 16, 24, '.');

            addChild(labelAtlas, 0, PerformanceParticleTest.kTagLabelAtlas);
            labelAtlas.position = new CCPoint(s.width - 66, 50);

            // Next Prev Test
            ParticleMenuLayer pMenu = new ParticleMenuLayer(true, PerformanceParticleTest.TEST_COUNT, PerformanceParticleTest.s_nParCurIdx);

            addChild(pMenu, 1, PerformanceParticleTest.kTagMenuLayer);

            // Sub Tests
            CCMenuItemFont.FontSize = 40;
            CCMenu pSubMenu = CCMenu.menuWithItems(null);

            for (int i = 1; i <= 6; ++i)
            {
                //char str[10] = {0};
                string str;
                //sprintf(str, "%d ", i);
                str = string.Format("{0:G}", i);
                CCMenuItemFont itemFont = CCMenuItemFont.itemFromString(str, this, testNCallback);
                itemFont.tag = i;
                pSubMenu.addChild(itemFont, 10);

                if (i <= 3)
                {
                    itemFont.Color = new ccColor3B(200, 20, 20);
                }
                else
                {
                    itemFont.Color = new ccColor3B(0, 200, 20);
                }
            }
            pSubMenu.alignItemsHorizontally();
            pSubMenu.position = new CCPoint(s.width / 2, 80);
            addChild(pSubMenu, 2);

            CCLabelTTF label = CCLabelTTF.labelWithString(title(), "Arial", 40);

            addChild(label, 1);
            label.position = new CCPoint(s.width / 2, s.height - 32);
            label.Color    = new ccColor3B(255, 255, 40);

            updateQuantityLabel();
            createParticleSystem();

            schedule(step);
        }
コード例 #27
0
ファイル: MenuTest.cs プロジェクト: trustme/cocos2d-mono
        public MenuTest()
        {
            CCDirector director = CCDirector.SharedDirector ();
            SizeF size = director.WinSize ();
            CCMenu menu = null;

            CCSprite spriteNormal = new CCSprite ("menuitemsprite.png", new RectangleF (0, 23 * 2, 115, 23));
            CCSprite spriteSelected = new CCSprite ("menuitemsprite.png", new RectangleF (0, 23 * 1, 115, 23));
            CCSprite spriteDisabled = new CCSprite ("menuitemsprite.png", new RectangleF (0, 23 * 0, 115, 23));
            CCMenuItemSprite item1 = new CCMenuItemSprite (spriteNormal, spriteSelected, spriteDisabled,
                delegate (NSObject sender) {
                CCScene scene1 = new CCScene ();
                scene1.AddChild (Layer2.Node());
                CCDirector.SharedDirector ().ReplaceScene (scene1);
            });

            CCMenuItemImage item2 = new CCMenuItemImage ("SendScoreButton.png", "SendScoreButtonPressed.png", null, cb);

            CCLabelAtlas labelAtlas = new CCLabelAtlas ("0123456789", "fps_images.png", 12, 32, '.');
            CCMenuItemLabel item3 = new CCMenuItemLabel(labelAtlas,
                delegate (NSObject sender) {
                CCDirector.SharedDirector ().EventDispatcher.AddMouseDelegate (this, -128-1);
                this.Schedule (new MonoMac.ObjCRuntime.Selector ("allowTouches"), 5.0f);
            });

            item3.DisabledColor = new ccColor3B (32, 32, 64);
            item3.Color = new ccColor3B (200, 200, 255);
            disabledItem = item3;

            CCMenuItemFont item4 = new CCMenuItemFont ("I toggle enabled items",
                delegate {
                disabledItem.Enabled = !disabledItem.Enabled;
            }
            );
            item4.FontSize = 20;
            item4.FontName = "Marker Felt";

            CCLabelBMFont label = new CCLabelBMFont ("configuration", "bitmapFontTest3.fnt");
            CCMenuItemLabel item5 = new CCMenuItemLabel (label,
                delegate {
                CCScene scene = new CCScene ();
                scene.AddChild (new Layer4 ());
                CCDirector.SharedDirector ().ReplaceScene (scene);
            });
            item5.Scale = 0.8f;

            CCMenuItemFont.DefaultFontName = "Marker Felt";
            CCMenuItemFont item6 = new CCMenuItemFont ("Priority Test",
                delegate (NSObject sender) {
                CCScene scene = new CCScene();
                scene.AddChild (new LayerPriorityTest());
                CCDirector.SharedDirector ().PushScene (scene);
            });

            CCMenuItemFont.DefaultFontName = "Courier New";
            CCMenuItemFont.DefaultFontSize = 30;
            CCMenuItemFont item7 = new CCMenuItemFont ("Quit",
                delegate {
                director.View.Window.Close ();
            });

            CCTintBy color_action = new CCTintBy(0.5f, 0, -255, -255);
            var color_back = color_action.Reverse ();
            var seq = new CCSequence (color_action, color_back);
            item7.RunAction (new CCRepeatForever (seq));

            menu = new CCMenu (item1, item2, item3, item4, item5, item6, item7);
            menu.AlignItemsVertically ();

            for (uint i = 0; i < menu.Children.Count(); i++) {
                CCNode child = (CCNode)menu.Children.ObjectAtIndex(i);
                PointF dstPoint = child.Position;
                int offset = (int)(size.Width/2) + 50;
                if (i % 2 == 0)
                    offset = -offset;
                child.Position = new PointF(dstPoint.X + offset, dstPoint.Y);
                child.RunAction(new CCEaseElasticOut(
                    new CCMoveBy(2, new PointF(dstPoint.X - offset, 0)), 0.35f));
            }

            menu.Position = new PointF(size.Width/2, size.Height/2);
            this.AddChild(menu);
        }
コード例 #28
0
ファイル: MenuLayer1.cs プロジェクト: chengcong/cocos2d-xna
        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);
        }
コード例 #29
0
        public virtual void initWithSubTest(int asubtest, int particles)
        {
            //srandom(0);

            subtestNumber = asubtest;
            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            lastRenderedCount = 0;
            quantityParticles = particles;

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

            CCLabel infoLabel = new CCLabel("0 nodes", "Marker Felt", 30, CCLabelFormat.SpriteFont);

            infoLabel.Color    = new CCColor3B(0, 200, 20);
            infoLabel.Position = new CCPoint(s.Width / 2, s.Height - 90);
            AddChild(infoLabel, 1, PerformanceParticleTest.kTagInfoLayer);

            // particles on stage
            CCLabelAtlas labelAtlas = new CCLabelAtlas("0000", "Images/fps_Images", 12, 32, '.');

            AddChild(labelAtlas, 0, PerformanceParticleTest.kTagLabelAtlas);
            labelAtlas.Position = new CCPoint(s.Width - 66, 50);

            // Next Prev Test
            ParticleMenuLayer pMenu = new ParticleMenuLayer(true, PerformanceParticleTest.TEST_COUNT, PerformanceParticleTest.s_nParCurIdx);

            AddChild(pMenu, 1, PerformanceParticleTest.kTagMenuLayer);

            // Sub Tests
            CCMenuItemFont.FontSize = 38;
            CCMenuItemFont.FontName = "arial";
            CCMenu pSubMenu = new CCMenu(null);

            for (int i = 1; i <= 6; ++i)
            {
                //char str[10] = {0};
                string str;
                //sprintf(str, "%d ", i);
                str = string.Format("{0:G}", i);
                CCMenuItemFont itemFont = new CCMenuItemFont(str, testNCallback);
                itemFont.Tag = i;
                pSubMenu.AddChild(itemFont, 10);

                if (i <= 3)
                {
                    itemFont.Color = new CCColor3B(200, 20, 20);
                }
                else
                {
                    itemFont.Color = new CCColor3B(0, 200, 20);
                }
            }
            pSubMenu.AlignItemsHorizontally();
            pSubMenu.Position = new CCPoint(s.Width / 2, 80);
            AddChild(pSubMenu, 2);

            CCLabel label = new CCLabel(title(), "arial", 38, CCLabelFormat.SpriteFont);

            AddChild(label, 1);
            label.Position = new CCPoint(s.Width / 2, s.Height - 32);
            label.Color    = new CCColor3B(255, 255, 40);

            updateQuantityLabel();
            createParticleSystem();

            Schedule(step);
        }