Exemple #1
0
        public AtlasBitmapColor()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            CCLabelBMFont label = null;

            label       = new CCLabelBMFont("Blue", "fonts/bitmapFontTest5.fnt");
            label.Color = ccBLUE;
            AddChild(label);
            label.Position    = new CCPoint(s.Width / 2, s.Height / 4);
            label.AnchorPoint = new CCPoint(0.5f, 0.5f);

            label = new CCLabelBMFont("Red", "fonts/bitmapFontTest5.fnt");
            AddChild(label);
            label.Position    = new CCPoint(s.Width / 2, 2 * s.Height / 4);
            label.AnchorPoint = new CCPoint(0.5f, 0.5f);
            label.Color       = ccRED;

            label = new CCLabelBMFont("G", "fonts/bitmapFontTest5.fnt");
            AddChild(label);
            label.Position    = new CCPoint(s.Width / 2, 3 * s.Height / 4);
            label.AnchorPoint = new CCPoint(0.5f, 0.5f);
            label.Color       = ccGREEN;
            label.Label       = ("Green");
        }
Exemple #2
0
        public ScrollViewLabelTest()
        {
            string       Font       = "fonts/futura-48.fnt";
            float        w          = CCDirector.SharedDirector.WinSize.Width;
            float        h          = CCDirector.SharedDirector.WinSize.Height / 2f;
            CCScrollView scrollView = new CCScrollView(new CCSize(w, h));

            scrollView.Direction = CCScrollViewDirection.Vertical;
            CCLabelBMFont testLabel = new CCLabelBMFont("Remeber we are the original XNA port of Cocos2d-X", Font);
            float         scale     = w / testLabel.ContentSize.Width;
            //Note, the scrollview requires the exact location. That's why first I need to set the scale, then SetString, so the label takes the correct size immediately.
            string text = "Thank you for visiting the cocos2d-xna tests\nPlease help us by donating to our project\nYou can find us at www.cocos2dxna.com\nRemeber we are the original XNA port of Cocos2d-X\n\n\nYou can also email us at [email protected]\n\nThank you!\n\nDon't forget to contribute to cocos2d-x\nWithout them this project would not exist.";
            //
            // The following hack is required to make the label properly show in the view.
            //
            // text = text.Replace(Environment.NewLine, "\n").Replace("\r\n", "\n").Replace("\n", " \n "); // @@ hack
            CCLabelBMFont descLabel = new CCLabelBMFont(text, Font, w);

            descLabel.LineBreakWithoutSpace = true;
            descLabel.Scale = scale;
            descLabel.SetString(text, true);
            descLabel.AnchorPoint       = new CCPoint(0, 0);
            descLabel.Color             = new CCColor3B(255, 255, 210);
            scrollView.Bounceable       = false;
            scrollView.ClippingToBounds = true;
            scrollView.MinScale         = scrollView.MaxScale = scrollView.ZoomScale = 1;
            scrollView.AddChild(descLabel, 0, 0);

            scrollView.AnchorPoint = new CCPoint(0, 0);
            scrollView.Position    = new CCPoint(0f, 45f);
            scrollView.ContentSize = new CCSize(w, Math.Max(h, descLabel.ContentSize.Height));
            scrollView.SetContentOffset(new CCPoint(0, Math.Min(0, scrollView.BoundingBox.Size.Height - scrollView.Container.ContentSize.Height)), false);
            AddChild(scrollView);
        }
Exemple #3
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;
        }
 public LabelBMFontChinese()
 {
     CCSize size = CCDirector.SharedDirector.WinSize;
     var pLable = new CCLabelBMFont("中国", "fonts/bitmapFontChinese.fnt");
     pLable.Position = new CCPoint(size.Width / 2, size.Height / 2);
     AddChild(pLable);
 }
Exemple #5
0
        public IntervalLayer()
        {
            m_time0 = m_time1 = m_time2 = m_time3 = m_time4 = 0.0f;

            CCSize s = CCDirector.SharedDirector.WinSize;

            // sun
            CCParticleSystem sun = new CCParticleSun();
            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");

            ScheduleUpdate();

            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 (
                (CCActionInterval) (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);
        }
Exemple #6
0
        public LabelBMFontHD()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            // CCLabelBMFont
            CCLabelBMFont label1 = new CCLabelBMFont("TESTING RETINA DISPLAY", "fonts/konqa32.fnt");
            AddChild(label1);
            label1.Position = new CCPoint(s.Width / 2, s.Height / 2);
        }
Exemple #7
0
        public Atlas4()
        {
            m_time = 0;

            // Upper Label
            CCLabelBMFont label = new CCLabelBMFont("Bitmap Font Atlas", "fonts/bitmapFontTest.fnt");

            AddChild(label);

            CCSize s = CCDirector.SharedDirector.WinSize;

            label.Position    = new CCPoint(s.Width / 2, s.Height / 2);
            label.AnchorPoint = new CCPoint(0.5f, 0.5f);


            CCSprite BChar = (CCSprite)label.GetChildByTag(1);
            CCSprite FChar = (CCSprite)label.GetChildByTag(7);
            CCSprite AChar = (CCSprite)label.GetChildByTag(12);


            CCActionInterval rotate    = new CCRotateBy(2, 360);
            CCAction         rot_4ever = new CCRepeatForever(rotate);

            CCActionInterval scale = new CCScaleBy(2, 1.5f);
            //CCActionInterval scale_back = scale.reverse();
            CCActionInterval   scale_back  = null;
            CCFiniteTimeAction scale_seq   = CCSequence.FromActions(scale, scale_back, null);
            CCAction           scale_4ever = new CCRepeatForever((CCActionInterval)scale_seq);

            CCActionInterval jump       = new CCJumpBy(0.5f, new CCPoint(), 60, 1);
            CCAction         jump_4ever = new CCRepeatForever(jump);

            CCActionInterval   fade_out   = new CCFadeOut(1);
            CCActionInterval   fade_in    = new CCFadeIn(1);
            CCFiniteTimeAction seq        = CCSequence.FromActions(fade_out, fade_in, null);
            CCAction           fade_4ever = new CCRepeatForever((CCActionInterval)seq);

            BChar.RunAction(rot_4ever);
            BChar.RunAction(scale_4ever);
            FChar.RunAction(jump_4ever);
            AChar.RunAction(fade_4ever);


            // Bottom Label
            CCLabelBMFont label2 = new CCLabelBMFont("00.0", "fonts/bitmapFontTest.fnt");

            AddChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2);
            label2.Position = new CCPoint(s.Width / 2.0f, 80);

            CCSprite lastChar = (CCSprite)label2.GetChildByTag(3);

            lastChar.RunAction((CCAction)(rot_4ever.Copy()));

            //schedule( schedule_selector(Atlas4::step), 0.1f);
            base.Schedule(step, 0.1f);
        }
Exemple #8
0
        public Atlas5()
        {
            CCLabelBMFont label = new CCLabelBMFont("abcdefg", "fonts/bitmapFontTest4.fnt");
            AddChild(label);

            CCSize s = CCDirector.SharedDirector.WinSize;

            label.Position = new CCPoint(s.Width / 2, s.Height / 2);
            label.AnchorPoint = new CCPoint(0.5f, 0.5f);
        }
Exemple #9
0
        public LabelBMFontHD()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            // CCLabelBMFont
            CCLabelBMFont label1 = new CCLabelBMFont("TESTING RETINA DISPLAY", "fonts/konqa32.fnt");

            AddChild(label1);
            label1.Position = new CCPoint(s.Width / 2, s.Height / 2);
        }
Exemple #10
0
        public BMFontInit()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            var bmFont = new CCLabelBMFont();
            //CCLabelBMFont* bmFont = [CCLabelBMFont create:@"Foo" fntFile:@"arial-unicode-26"];
            bmFont.FntFile = "fonts/helvetica-32.fnt";
            bmFont.Text = ("It is working!");
            AddChild(bmFont);
            bmFont.Position = new CCPoint(s.Width / 2, s.Height / 4 * 2);
        }
Exemple #11
0
        public Atlas5()
        {
            CCLabelBMFont label = new CCLabelBMFont("abcdefg", "fonts/bitmapFontTest4.fnt");

            AddChild(label);

            CCSize s = CCDirector.SharedDirector.WinSize;

            label.Position    = new CCPoint(s.Width / 2, s.Height / 2);
            label.AnchorPoint = new CCPoint(0.5f, 0.5f);
        }
        public LabelGlyphDesigner()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            CCLayerColor layer = new CCLayerColor(new CCColor4B(128, 128, 128, 255));
            AddChild(layer, -10);

            // CCLabelBMFont
            CCLabelBMFont label1 = new CCLabelBMFont("Testing Glyph Designer", "fonts/futura-48.fnt");
            AddChild(label1);
            label1.Position = new CCPoint(s.Width / 2, s.Height / 2);
        }
Exemple #13
0
        public Issue1343()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            var bmFont = new CCLabelBMFont();
            bmFont.FntFile = "fonts/font-issue1343.fnt";
            bmFont.Text = ("ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz.,'");
            AddChild(bmFont);
            bmFont.Scale = 0.3f;

            bmFont.Position = new CCPoint(s.Width / 2, s.Height / 4 * 2);
        }
Exemple #14
0
        public Atlas4()
        {
            m_time = 0;

            // Upper Label
            CCLabelBMFont label = new CCLabelBMFont("Bitmap Font Atlas", "fonts/bitmapFontTest.fnt");
            AddChild(label);

            CCSize s = CCDirector.SharedDirector.WinSize;

            label.Position = new CCPoint(s.Width / 2, s.Height / 2);
            label.AnchorPoint = new CCPoint(0.5f, 0.5f);


            CCSprite BChar = (CCSprite)label.GetChildByTag(0);
            CCSprite FChar = (CCSprite)label.GetChildByTag(7);
            CCSprite AChar = (CCSprite)label.GetChildByTag(12);


            CCActionInterval rotate = new CCRotateBy (2, 360);
            CCAction rot_4ever = new CCRepeatForever (rotate);

            CCActionInterval scale = new CCScaleBy(2, 1.5f);
            CCFiniteTimeAction scale_back = scale.Reverse();
            CCFiniteTimeAction scale_seq = new CCSequence(scale, scale_back);
            CCAction scale_4ever = new CCRepeatForever ((CCActionInterval)scale_seq);

            CCActionInterval jump = new CCJumpBy (0.5f, new CCPoint(), 60, 1);
            CCAction jump_4ever = new CCRepeatForever (jump);

            CCActionInterval fade_out = new CCFadeOut  (1);
            CCActionInterval fade_in = new CCFadeIn  (1);
            CCFiniteTimeAction seq = new CCSequence(fade_out, fade_in);
            CCAction fade_4ever = new CCRepeatForever ((CCActionInterval)seq);

            BChar.RunAction(rot_4ever);
            BChar.RunAction(scale_4ever);
            FChar.RunAction(jump_4ever);
            AChar.RunAction(fade_4ever);


            // Bottom Label
            CCLabelBMFont label2 = new CCLabelBMFont("00.0", "fonts/bitmapFontTest.fnt");
            AddChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2);
            label2.Position = new CCPoint(s.Width / 2.0f, 80);

            CCSprite lastChar = (CCSprite)label2.GetChildByTag(3);
            lastChar.RunAction((CCAction)(rot_4ever.Copy()));

            //schedule( schedule_selector(Atlas4::step), 0.1f);
            base.Schedule(step, 0.1f);
        }
Exemple #15
0
        public BMFontOneAtlas()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            CCLabelBMFont label1 = new CCLabelBMFont("This is Helvetica", "fonts/helvetica-32.fnt", CCLabelBMFont.kCCLabelAutomaticWidth,
                                                        CCTextAlignment.Left, CCPoint.Zero);
            AddChild(label1);
            label1.Position = new CCPoint(s.Width / 2, s.Height / 3 * 2);

            CCLabelBMFont label2 = new CCLabelBMFont("And this is Geneva", "fonts/geneva-32.fnt", CCLabelBMFont.kCCLabelAutomaticWidth,
                                                        CCTextAlignment.Left, new CCPoint(0, 128));
            AddChild(label2);
            label2.Position = new CCPoint(s.Width / 2, s.Height / 3 * 1);
        }
Exemple #16
0
        public virtual void step(float dt)
        {
            m_time += dt;
            //char string[10] = {0};
            string Stepstring;

            //sprintf(string, "%04.1f", m_time);
            Stepstring = string.Format("{0,4:1f}", m_time);
            //  std::string string;
            //  string.format("%04.1f", m_time);

            CCLabelBMFont label1 = (CCLabelBMFont)GetChildByTag((int)TagSprite.kTagBitmapAtlas2);

            label1.Label = (Stepstring);
        }
Exemple #17
0
        public override void OnEnter()
        {
            base.OnEnter();

            var s = CCDirector.SharedDirector.WinSize;
            var layer1 = new CCLayerRGBA();

            var sister1 = new CCSprite("Images/grossinis_sister1.png");
            var sister2 = new CCSprite("Images/grossinis_sister2.png");
            var label = new CCLabelBMFont("Test", "fonts/bitmapFontTest.fnt");
    
            layer1.AddChild(sister1);
            layer1.AddChild(sister2);
            layer1.AddChild(label);
            this.AddChild( layer1, 0, kTagLayer);
    
            sister1.Position= new CCPoint( s.Width*1/3, s.Height/2);
            sister2.Position = new CCPoint( s.Width*2/3, s.Height/2);
            label.Position = new CCPoint(s.Width / 2, s.Height / 2);

            layer1.RunAction(
                new CCRepeatForever(
                    CCSequence.FromActions(
                        new CCFadeTo(4, 0),
                        new CCFadeTo(4, 255),
                        new CCDelayTime(1))
                    )
                );

            sister1.RunAction(
                new CCRepeatForever(
                    CCSequence.FromActions(
                        new CCFadeTo(2, 0),
                        new CCFadeTo(2, 255),
                        new CCFadeTo(2, 0),
                        new CCFadeTo(2, 255),
                        new CCDelayTime(1))
                    )
                );
    
    
            // Enable cascading in scene
            SetEnableRecursiveCascading(this, true);
        }
        public AtlasFastBitmap()
        {
            // Upper Label
            for (int i = 0; i < 100; i++)
            {
                //char str[6] = {0};
                string str;
                //sprintf(str, "-%d-", i);
                str = string.Format("-{0}-", i);
                CCLabelBMFont label = new CCLabelBMFont(str, "fonts/bitmapFontTest.fnt");
                AddChild(label);

                CCSize s = CCDirector.SharedDirector.WinSize;

                CCPoint p = new CCPoint(CCMacros.CCRandomBetween0And1() * s.Width, CCMacros.CCRandomBetween0And1() * s.Height);
                label.Position = p;
                label.AnchorPoint = new CCPoint(0.5f, 0.5f);
            }
        }
Exemple #19
0
        public Atlas3()
        {
            m_time = 0;

            CCLayerColor col = new CCLayerColor(new CCColor4B(128, 128, 128, 255));
            AddChild(col, -10);

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

            // testing anchors
            label1.AnchorPoint = new CCPoint(0, 0);
            AddChild(label1, 0, (int)TagSprite.kTagBitmapAtlas1);
            CCActionInterval fade = new CCFadeOut  (1.0f);
            CCFiniteTimeAction fade_in = fade.Reverse();
            CCFiniteTimeAction seq = CCSequence.FromActions(fade, fade_in);
            CCAction repeat = new CCRepeatForever ((CCActionInterval)seq);
            label1.RunAction(repeat);


            // VERY IMPORTANT
            // color and opacity work OK because bitmapFontAltas2 loads a BMP image (not a PNG image)
            // If you want to use both opacity and color, it is recommended to use NON premultiplied images like BMP images
            // Of course, you can also tell XCode not to compress PNG images, but I think it doesn't work as expected
            CCLabelBMFont label2 = new CCLabelBMFont("Test", "fonts/bitmapFontTest2.fnt");
            // testing anchors
            label2.AnchorPoint = new CCPoint(0.5f, 0.5f);
            label2.Color = ccRED;
            AddChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2);
            label2.RunAction((CCAction)(repeat.Copy()));

            CCLabelBMFont label3 = new CCLabelBMFont("Test", "fonts/bitmapFontTest2.fnt");
            // testing anchors
            label3.AnchorPoint = new CCPoint(1, 1);
            AddChild(label3, 0, (int)TagSprite.kTagBitmapAtlas3);


            CCSize s = CCDirector.SharedDirector.WinSize;
            label1.Position = new CCPoint();
            label2.Position = new CCPoint(s.Width / 2, s.Height / 2);
            label3.Position = new CCPoint(s.Width, s.Height);

            base.Schedule(step);//:@selector(step:)];
        }
Exemple #20
0
 public override void Update(float dt)
 {
     elapsed += dt;
     if (elapsed > 0.5f)
     {
         elapsed = 0f;
         // CCLabelBMFont
         if (label1 != null)
         {
             RemoveChild(label1);
         }
         CCSize s = CCDirector.SharedDirector.WinSize;
         float x = s.Width * CCMacros.CCRandomBetween0And1();
         float y = s.Height * CCMacros.CCRandomBetween0And1();
         label1 = new CCLabelBMFont(string.Format("{0:N2},{1:N2} @ MEMORY LEAK", x, y), "fonts/konqa32.fnt");
         AddChild(label1);
         label1.Position = new CCPoint(x, y);
     }
 }
Exemple #21
0
        public AtlasFastBitmap()
        {
            // Upper Label
            for (int i = 0; i < 100; i++)
            {
                //char str[6] = {0};
                string str;
                //sprintf(str, "-%d-", i);
                str = string.Format("-{0,d}-", i);
                CCLabelBMFont label = new CCLabelBMFont(str, "fonts/bitmapFontTest.fnt");
                AddChild(label);

                CCSize s = CCDirector.SharedDirector.WinSize;

                CCPoint p = new CCPoint(CCMacros.CCRandomBetween0And1() * s.Width, CCMacros.CCRandomBetween0And1() * s.Height);
                label.Position    = p;
                label.AnchorPoint = new CCPoint(0.5f, 0.5f);
            }
        }
Exemple #22
0
        protected void PurgeDirector()
        {
            // cleanup scheduler
            Scheduler.UnscheduleAll();

            // don't release the event handlers
            // They are needed in case the director is run again
            m_pTouchDispatcher.RemoveAllDelegates();

            if (m_pRunningScene != null)
            {
                m_pRunningScene.OnExitTransitionDidStart();
                m_pRunningScene.OnExit();
                m_pRunningScene.Cleanup();
            }

            m_pRunningScene = null;
            m_pNextScene    = null;

            // remove all objects, but don't release it.
            // runWithScene might be executed after 'end'.
            m_pobScenesStack.Clear();

            StopAnimation();

            // purge bitmap cache
            CCLabelBMFont.PurgeCachedData();

            // purge all managed caches
            CCAnimationCache.PurgeSharedAnimationCache();
            CCSpriteFrameCache.PurgeSharedSpriteFrameCache();
            CCTextureCache.PurgeSharedTextureCache();
            // CCFileUtils.PurgeFileUtils();
            // CCConfiguration.purgeConfiguration();

            // cocos2d-x specific data structures
            CCUserDefault.PurgeSharedUserDefault();
            // CCNotificationCenter.purgeNotificationCenter();

            CCDrawManager.PurgeDrawManager();

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

            CCSize s = CCDirector.SharedDirector.WinSize;

            // add title
            CCLabelTTF label = new CCLabelTTF(title(), "arial", 32);
            AddChild(label, 1);
            label.Position = new CCPoint(s.Width / 2, s.Height - 50);
            CCNode ccnode = new CCNode();
            ccnode.ScheduleUpdate();

            m_plabel = new CCLabelBMFont("00.0", "fonts/arial16.fnt");
            m_plabel.Position = new CCPoint(s.Width / 2, s.Height / 2);
            AddChild(m_plabel);

            elapsedTime = 0;
            numberOfTouchesB = numberOfTouchesM = numberOfTouchesE = numberOfTouchesC = 0;
        }
Exemple #24
0
        public Atlas6()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            CCLabelBMFont label = null;
            label = new CCLabelBMFont("FaFeFiFoFu", "fonts/bitmapFontTest5.fnt");
            AddChild(label);
            label.Position = new CCPoint(s.Width / 2, s.Height / 2 + 50);
            label.AnchorPoint = new CCPoint(0.5f, 0.5f);

            label = new CCLabelBMFont("fafefifofu", "fonts/bitmapFontTest5.fnt");
            AddChild(label);
            label.Position = new CCPoint(s.Width / 2, s.Height / 2);
            label.AnchorPoint = new CCPoint(0.5f, 0.5f);

            label = new CCLabelBMFont("aeiou", "fonts/bitmapFontTest5.fnt");
            AddChild(label);
            label.Position = new CCPoint(s.Width / 2, s.Height / 2 - 50);
            label.AnchorPoint = new CCPoint(0.5f, 0.5f);
        }
Exemple #25
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);
        }
Exemple #26
0
        public override void OnEnter()
        {
            base.OnEnter();

            this.TouchEnabled = true;

            CCSize s = CCDirector.SharedDirector.WinSize;
            CCLayerColor layer = new CCLayerColor(new CCColor4B(0xFF, 0x00, 0x00, 0x80), s.Width * 0.75f, s.Height * 0.75f);

            layer.IgnoreAnchorPointForPosition = false;
            layer.Position = (new CCPoint(s.Width / 2, s.Height / 2));
            AddChild(layer, 1, kTagLayer);
            //
            // Add two labels using BM label class
            // CCLabelBMFont
            CCLabelBMFont label1 = new CCLabelBMFont("LABEL1", "fonts/konqa32.fnt");
            layer.AddChild(label1);
            label1.Position = new CCPoint(layer.ContentSize.Width / 2, layer.ContentSize.Height * 0.75f);
            CCLabelBMFont label2 = new CCLabelBMFont("LABEL2", "fonts/konqa32.fnt");
            layer.AddChild(label2);
            label2.Position = new CCPoint(layer.ContentSize.Width / 2, layer.ContentSize.Height * 0.25f);
            //
            // Do the sequence of actions in the bug report
            float waitTime = 3f;
            float runTime = 12f;
            layer.Visible = false;
            CCHide hide = new CCHide();
            CCScaleTo scaleTo1 = new CCScaleTo(0.0f, 0.0f);
            CCShow show = new CCShow();
            CCDelayTime delay = new CCDelayTime (waitTime);
            CCScaleTo scaleTo2 = new CCScaleTo(runTime * 0.25f, 1.2f);
            CCScaleTo scaleTo3 = new CCScaleTo(runTime * 0.25f, 0.95f);
            CCScaleTo scaleTo4 = new CCScaleTo(runTime * 0.25f, 1.1f);
            CCScaleTo scaleTo5 = new CCScaleTo(runTime * 0.25f, 1.0f);

            CCFiniteTimeAction seq = new CCSequence(hide, scaleTo1, show, delay, scaleTo2, scaleTo3, scaleTo4, scaleTo5);

            layer.RunAction(seq);


        }
Exemple #27
0
        public Atlas6()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            CCLabelBMFont label = null;

            label = new CCLabelBMFont("FaFeFiFoFu", "fonts/bitmapFontTest5.fnt");
            AddChild(label);
            label.Position    = new CCPoint(s.Width / 2, s.Height / 2 + 50);
            label.AnchorPoint = new CCPoint(0.5f, 0.5f);

            label = new CCLabelBMFont("fafefifofu", "fonts/bitmapFontTest5.fnt");
            AddChild(label);
            label.Position    = new CCPoint(s.Width / 2, s.Height / 2);
            label.AnchorPoint = new CCPoint(0.5f, 0.5f);

            label = new CCLabelBMFont("aeiou", "fonts/bitmapFontTest5.fnt");
            AddChild(label);
            label.Position    = new CCPoint(s.Width / 2, s.Height / 2 - 50);
            label.AnchorPoint = new CCPoint(0.5f, 0.5f);
        }
Exemple #28
0
        public BitmapFontMultiLine()
        {
            CCSize s;

            // Left
            CCLabelBMFont label1 = new CCLabelBMFont("Multi line\nLeft", "fonts/bitmapFontTest3.fnt");

            label1.AnchorPoint = new CCPoint(0, 0);
            AddChild(label1, 0, (int)TagSprite.kTagBitmapAtlas1);

            s = label1.ContentSize;

            //CCLOG("content size: %.2fx%.2f", s.width, s.height);
            CCLog.Log("content size: {0,0:2f}x{1,0:2f}", s.Width, s.Height);


            // Center
            CCLabelBMFont label2 = new CCLabelBMFont("Multi line\nCenter", "fonts/bitmapFontTest3.fnt");

            label2.AnchorPoint = new CCPoint(0.5f, 0.5f);
            AddChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2);

            s = label2.ContentSize;
            //CCLOG("content size: %.2fx%.2f", s.width, s.height);
            CCLog.Log("content size: {0,0:2f}x{1,0:2f}", s.Width, s.Height);

            // right
            CCLabelBMFont label3 = new CCLabelBMFont("Multi line\nRight\nThree lines Three", "fonts/bitmapFontTest3.fnt");

            label3.AnchorPoint = new CCPoint(1, 1);
            AddChild(label3, 0, (int)TagSprite.kTagBitmapAtlas3);

            s = label3.ContentSize;
            //CCLOG("content size: %.2fx%.2f", s.width, s.height);

            s = CCDirector.SharedDirector.WinSize;
            label1.Position = new CCPoint();
            label2.Position = new CCPoint(s.Width / 2, s.Height / 2);
            label3.Position = new CCPoint(s.Width, s.Height);
        }
        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;
        }
Exemple #30
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.Label = ("not empty");
                label2.Label = ("not empty");
                label3.Label = ("hi");

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

                setEmpty = false;
            }
        }
        public BitmapFontMultiLine()
        {
            CCSize s;

            // Left
            CCLabelBMFont label1 = new CCLabelBMFont("Multi line\nLeft", "fonts/bitmapFontTest3.fnt");
            label1.AnchorPoint = new CCPoint(0, 0);
            AddChild(label1, 0, (int)TagSprite.kTagBitmapAtlas1);

            s = label1.ContentSize;

            //CCLOG("content size: %.2fx%.2f", s.width, s.height);
            CCLog.Log("content size: {0,0:2f}x{1,0:2f}", s.Width, s.Height);


            // Center
            CCLabelBMFont label2 = new CCLabelBMFont("Multi line\nCenter", "fonts/bitmapFontTest3.fnt");
            label2.AnchorPoint = new CCPoint(0.5f, 0.5f);
            AddChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2);

            s = label2.ContentSize;
            //CCLOG("content size: %.2fx%.2f", s.width, s.height);
            CCLog.Log("content size: {0,0:2f}x{1,0:2f}", s.Width, s.Height);

            // right
            CCLabelBMFont label3 = new CCLabelBMFont("Multi line\nRight\nThree lines Three", "fonts/bitmapFontTest3.fnt");
            label3.AnchorPoint = new CCPoint(1, 1);
            AddChild(label3, 0, (int)TagSprite.kTagBitmapAtlas3);

            s = label3.ContentSize;
            //CCLOG("content size: %.2fx%.2f", s.width, s.height);

            s = CCDirector.SharedDirector.WinSize;
            label1.Position = new CCPoint();
            label2.Position = new CCPoint(s.Width / 2, s.Height / 2);
            label3.Position = new CCPoint(s.Width, s.Height);
        }
        public AtlasBitmapColor()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            CCLabelBMFont label = null;
            label = new CCLabelBMFont("Blue", "fonts/bitmapFontTest5.fnt");
            label.Color = ccBLUE;
            AddChild(label);
            label.Position = new CCPoint(s.Width / 2, s.Height / 4);
            label.AnchorPoint = new CCPoint(0.5f, 0.5f);

            label = new CCLabelBMFont("Red", "fonts/bitmapFontTest5.fnt");
            AddChild(label);
            label.Position = new CCPoint(s.Width / 2, 2 * s.Height / 4);
            label.AnchorPoint = new CCPoint(0.5f, 0.5f);
            label.Color = ccRED;

            label = new CCLabelBMFont("G", "fonts/bitmapFontTest5.fnt");
            AddChild(label);
            label.Position = new CCPoint(s.Width / 2, 3 * s.Height / 4);
            label.AnchorPoint = new CCPoint(0.5f, 0.5f);
            label.Color = ccGREEN;
            label.Label = ("Green");
        }
Exemple #33
0
		public GameLayer ()
		{
			gameSuspended = true;
			var batchnode = GetChildByTag((int)Tags.SpriteManager) as CCSpriteBatchNode;

			InitPlatforms ();

			var bird = new CCSprite(batchnode.Texture, new CCRect(608,16,44,32));
			batchnode.AddChild (bird,4,(int)Tags.Bird);

			CCSprite bonus;
			
			for(int i=0; i<(int)Bonus.NumBonuses; i++) {
				bonus = new CCSprite(batchnode.Texture, new CCRect(608+i*32,256,25,25));
				batchnode.AddChild(bonus,4,(int)Tags.BomusStart+i);
				bonus.Visible = false;
			}

			var scoreLabel = new CCLabelBMFont("0", "Fonts/bitmapFont.fnt");
            scoreLabel.Position = new CCPoint(160,430);
			AddChild(scoreLabel, 5, (int)Tags.ScoreLabel);


		}
Exemple #34
0
        public BMFontUnicode()
        {
            var data = CCFileUtils.GetFileData("fonts/strings.plist");
            PlistDocument doc = new PlistDocument(data);
            var strings = doc.Root as PlistDictionary;

            string chinese = strings["chinese1"].AsString;
            string japanese = strings["japanese"].AsString;
            string spanish = strings["spanish"].AsString;

            CCSize s = CCDirector.SharedDirector.WinSize;

            CCLabelBMFont label1 = new CCLabelBMFont(spanish, "fonts/arial-unicode-26.fnt", 200, CCTextAlignment.Left);
            AddChild(label1);
            label1.Position = new CCPoint(s.Width / 2, s.Height / 4 * 3);

            CCLabelBMFont label2 = new CCLabelBMFont(chinese, "fonts/arial-unicode-26.fnt");
            AddChild(label2);
            label2.Position = new CCPoint(s.Width / 2, s.Height / 4 * 2);

            CCLabelBMFont label3 = new CCLabelBMFont(japanese, "fonts/arial-unicode-26.fnt");
            AddChild(label3);
            label3.Position = new CCPoint(s.Width / 2, s.Height / 4 * 1);
        }
Exemple #35
0
        public ScrollViewLabelTest()
        {
            string Font = "fonts/futura-48.fnt";
            float w = CCDirector.SharedDirector.WinSize.Width;
            float h = CCDirector.SharedDirector.WinSize.Height / 2f;
            CCScrollView scrollView = new CCScrollView(new CCSize(w, h));
            scrollView.Direction = CCScrollViewDirection.Vertical;
            CCLabelBMFont testLabel = new CCLabelBMFont("Remeber we are the original XNA port of Cocos2d-X", Font);
            float scale = w / testLabel.ContentSize.Width;
            //Note, the scrollview requires the exact location. That's why first I need to set the scale, then SetString, so the label takes the correct size immediately.
            string text = "Thank you for visiting the cocos2d-xna tests\nPlease help us by donating to our project\nYou can find us at www.cocos2dxna.com\nRemeber we are the original XNA port of Cocos2d-X\n\n\nYou can also email us at [email protected]\n\nThank you!\n\nDon't forget to contribute to cocos2d-x\nWithout them this project would not exist.";
            //
            // The following hack is required to make the label properly show in the view.
            //
            // text = text.Replace(Environment.NewLine, "\n").Replace("\r\n", "\n").Replace("\n", " \n "); // @@ hack
            CCLabelBMFont descLabel = new CCLabelBMFont(text, Font, w);
            descLabel.LineBreakWithoutSpace = true;
            descLabel.Scale = scale;
            descLabel.SetString(text, true);
            descLabel.AnchorPoint = new CCPoint(0, 0);
            descLabel.Color = new CCColor3B(255, 255, 210);
            scrollView.Bounceable = false;
            scrollView.ClippingToBounds = true;
            scrollView.MinScale = scrollView.MaxScale = scrollView.ZoomScale = 1;
            scrollView.AddChild(descLabel, 0, 0);

            scrollView.AnchorPoint = new CCPoint(0, 0);
            scrollView.Position = new CCPoint(0f, 45f);
            scrollView.ContentSize = new CCSize(w, Math.Max(h, descLabel.ContentSize.Height));
            scrollView.SetContentOffset(new CCPoint(0, Math.Min(0, scrollView.BoundingBox.Size.Height - scrollView.Container.ContentSize.Height)), false);
            AddChild(scrollView);
        }
Exemple #36
0
 public void PurgeCachedData()
 {
     CCLabelBMFont.PurgeCachedData();
     CCTextureCache.SharedTextureCache.RemoveAllTextures();
     //CCFileUtils::sharedFileUtils()->purgeCachedEntries();
 }
Exemple #37
0
        public override void OnEnter()
        {
            base.OnEnter();

            var s = CCDirector.SharedDirector.WinSize;
            var layer1 = new CCLayerColor(new CCColor4B(192, 0, 0, 255), s.Width, s.Height / 2);
            layer1.CascadeColorEnabled = false;

            layer1.Position = new CCPoint(0, s.Height / 2);

            var sister1 = new CCSprite("Images/grossinis_sister1.png");
            var sister2 = new CCSprite("Images/grossinis_sister2.png");
            var label = new CCLabelBMFont("Test", "fonts/bitmapFontTest.fnt");

            layer1.AddChild(sister1);
            layer1.AddChild(sister2);
            layer1.AddChild(label);
            this.AddChild(layer1, 0, kTagLayer);

            sister1.Position = new CCPoint(s.Width * 1 / 3, 0);
            sister2.Position = new CCPoint(s.Width * 2 / 3, 0);
            label.Position = new CCPoint(s.Width / 2, 0);

            layer1.RunAction(
                new CCRepeatForever(
                    CCSequence.FromActions(
                        new CCTintTo(6, 255, 0, 255),
                        new CCTintTo(6, 255, 255, 255),
                        new CCDelayTime(1))
                    )
                );

            sister1.RunAction(
                new CCRepeatForever(
                    CCSequence.FromActions(
                        new CCTintTo(2, 255, 255, 0),
                        new CCTintTo(2, 255, 255, 255),
                        new CCTintTo(2, 0, 255, 255),
                        new CCTintTo(2, 255, 255, 255),
                        new CCTintTo(2, 255, 0, 255),
                        new CCTintTo(2, 255, 255, 255),
                        new CCDelayTime(1))
                    )
                );
        }
        public BitmapFontMultiLineAlignment()
        {
            TouchEnabled = true;

            // ask director the the window size
            CCSize size = CCDirector.SharedDirector.WinSize;

            // create and initialize a Label
            m_pLabelShouldRetain = new CCLabelBMFont(LongSentencesExample, "fonts/markerFelt.fnt", size.Width / 1.5f,
                                                        CCTextAlignment.Center);

            m_pArrowsBarShouldRetain = new CCSprite("Images/arrowsBar");
            m_pArrowsShouldRetain = new CCSprite("Images/arrows");

            CCMenuItemFont.FontSize = 20;
            CCMenuItemFont longSentences = new CCMenuItemFont("Long Flowing Sentences", stringChanged);
            CCMenuItemFont lineBreaks = new CCMenuItemFont("Short Sentences With Intentional Line Breaks", stringChanged);
            CCMenuItemFont mixed = new CCMenuItemFont("Long Sentences Mixed With Intentional Line Breaks", stringChanged);
            CCMenu stringMenu = new CCMenu(longSentences, lineBreaks, mixed);
            stringMenu.AlignItemsVertically();

            longSentences.Color = CCTypes.CCRed;
            m_pLastSentenceItem = longSentences;
            longSentences.Tag = LongSentences;
            lineBreaks.Tag = LineBreaks;
            mixed.Tag = Mixed;

            CCMenuItemFont.FontSize = 30;

            CCMenuItemFont left = new CCMenuItemFont("Left", alignmentChanged);
            CCMenuItemFont center = new CCMenuItemFont("Center", alignmentChanged);
            CCMenuItemFont right = new CCMenuItemFont("Right", alignmentChanged);
            CCMenu alignmentMenu = new CCMenu(left, center, right);
            alignmentMenu.AlignItemsHorizontallyWithPadding(alignmentItemPadding);

            center.Color = CCTypes.CCRed;
            m_pLastAlignmentItem = center;
            left.Tag = (LeftAlign);
            center.Tag = (CenterAlign);
            right.Tag = (RightAlign);

            // position the label on the center of the screen
            m_pLabelShouldRetain.Position = new CCPoint(size.Width / 2, size.Height / 2);

            m_pArrowsBarShouldRetain.Visible = (false);

            float arrowsWidth = (ArrowsMax - ArrowsMin) * size.Width;
            m_pArrowsBarShouldRetain.ScaleX = (arrowsWidth / m_pArrowsBarShouldRetain.ContentSize.Width);
            m_pArrowsBarShouldRetain.Position = new CCPoint(((ArrowsMax + ArrowsMin) / 2) * size.Width, m_pLabelShouldRetain.Position.Y);

            snapArrowsToEdge();

            stringMenu.Position = new CCPoint(size.Width / 2, size.Height - menuItemPaddingCenter);
            alignmentMenu.Position = new CCPoint(size.Width / 2, menuItemPaddingCenter + 15);

            AddChild(m_pLabelShouldRetain);
            AddChild(m_pArrowsBarShouldRetain);
            AddChild(m_pArrowsShouldRetain);
            AddChild(stringMenu);
            AddChild(alignmentMenu);
        }
Exemple #39
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);
        }
Exemple #40
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);
        }
Exemple #41
0
        public override void OnEnter()
        {
            base.OnEnter();

            this.TouchEnabled = true;

            CCSize s = CCDirector.SharedDirector.WinSize;

            CCLayerColor layer1 = new CCLayerColor(new CCColor4B(0xFF, 0xFF, 0x00, 0x80), s.Width * 0.75f, s.Height * 0.75f);
            layer1.IgnoreAnchorPointForPosition = false;
            layer1.Position = (new CCPoint(s.Width / 2, s.Height / 2));
            layer1.ChildClippingMode = CCClipMode.Bounds;
            AddChild(layer1, 1);

            s = layer1.ContentSize;

            m_pInnerLayer = new CCLayerColor(new CCColor4B(0xFF, 0x00, 0x00, 0x80), s.Width * 0.5f, s.Height * 0.5f);
            m_pInnerLayer.IgnoreAnchorPointForPosition = false;
            m_pInnerLayer.Position = (new CCPoint(s.Width / 2, s.Height / 2));
            m_pInnerLayer.ChildClippingMode = CCClipMode.Bounds;
            
            layer1.AddChild(m_pInnerLayer, 1);
            
            //
            // Add two labels using BM label class
            // CCLabelBMFont
            CCLabelBMFont label1 = new CCLabelBMFont("LABEL1", "fonts/konqa32.fnt");
            label1.Position = new CCPoint(m_pInnerLayer.ContentSize.Width, m_pInnerLayer.ContentSize.Height * 0.75f);
            m_pInnerLayer.AddChild(label1);
            
            CCLabelBMFont label2 = new CCLabelBMFont("LABEL2", "fonts/konqa32.fnt");
            label2.Position = new CCPoint(0, m_pInnerLayer.ContentSize.Height * 0.25f);
            m_pInnerLayer.AddChild(label2);

            float runTime = 12f;

            CCScaleTo scaleTo2 = new CCScaleTo(runTime * 0.25f, 3.0f);
            CCScaleTo scaleTo3 = new CCScaleTo(runTime * 0.25f, 1.0f);

            CCFiniteTimeAction seq = new CCRepeatForever(
                new CCSequence(scaleTo2, scaleTo3)
                );

            m_pInnerLayer.RunAction(seq);

            CCSize size = CCDirector.SharedDirector.WinSize;

            var move1 = new CCMoveTo(2, new CCPoint(size.Width / 2, size.Height));
            var move2 = new CCMoveTo(2, new CCPoint(size.Width, size.Height / 2));
            var move3 = new CCMoveTo(2, new CCPoint(size.Width / 2, 0));
            var move4 = new CCMoveTo(2, new CCPoint(0, size.Height / 2));

            layer1.RunAction(new CCRepeatForever(new CCSequence(move1, move2, move3, move4)));

        }