当前位置: 首页>>代码示例>>C#>>正文


C# CocosSharp.CCLabel类代码示例

本文整理汇总了C#中CocosSharp.CCLabel的典型用法代码示例。如果您正苦于以下问题:C# CCLabel类的具体用法?C# CCLabel怎么用?C# CCLabel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CCLabel类属于CocosSharp命名空间,在下文中一共展示了CCLabel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LabelFNTPadding

        public LabelFNTPadding()
        {
			label = new CCLabel("abcdefg", "fonts/bitmapFontTest4.fnt");
            AddChild(label);

			label.AnchorPoint = CCPoint.AnchorMiddle;
        }
开发者ID:KevinHeyer,项目名称:CocosSharp,代码行数:7,代码来源:LabelFNTPadding.cs

示例2: GameLayer

        //^Each character needed it's own CCSprite to go with a weapon, only one instance of a CCSprite shows in game


        public GameLayer() : base("level_" + CCRandom.GetRandomInt(3, numLevels) + ".tmx"/*"level_5.tmx"*/) // get a random level and load it on initialization
        {
            character.map = this;
            //touch listener - calles tileHandler to handle tile touches
            touchListener = new CCEventListenerTouchAllAtOnce();
            touchListener.OnTouchesEnded = handleEndTouches;
            AddEventListener(touchListener);

            loopTiles(null);
            //Schedule the main game loop
            enemiesList = placeEnemiesRandomly();
            foreach (character enemy in enemiesList)
                this.AddChild(enemy);

            //Add labels to the upper left hand corner
            //Might be better to have a bar with width based on a percentage of health/maxhealth
            userInfo = new CCLabel
                ("Health: " + user.health + "/" + user.maxHealth + "    Attack : " + user.weapon.attack,"arial",12);
            userInfo.Position = new CCPoint(70, VisibleBoundsWorldspace.UpperRight.Y + 5);
            userInfo.IsAntialiased = true;
            this.AddChild(userInfo);

            //run main game loop - frames happen every 1 second
            Schedule(RunGameLogic,(float)0.5);
        }
开发者ID:jacobmcrandall,项目名称:POOPCrawler,代码行数:28,代码来源:GameLayer.cs

示例3: StartScene

        public StartScene(CCWindow mainWindow)
            : base(mainWindow)
        {
            mainLayer = new CCLayer ();
            AddChild (mainLayer);

            PlayButton = new CCSprite ("logo");

            NameLabel = new CCLabel ("Map Knight - Alpha", "arial", 22);
            CreatorLabel = new CCLabel ("Created by tipfom and Exo", "arial", 22);
            VersionLabel = new CCLabel ("Version unspecified", "arial", 22);
            InfoLabel = new CCLabel ("Click to play", "arial", 22);

            PlayButton.ScaleX = mainWindow.WindowSizeInPixels.Width / PlayButton.ContentSize.Width;
            PlayButton.ScaleY = mainWindow.WindowSizeInPixels.Height / PlayButton.ContentSize.Height;
            PlayButton.Position = new CCPoint (PlayButton.ScaledContentSize.Width / 2, PlayButton.ScaledContentSize.Height / 2);

            NameLabel.Position = new CCPoint (mainWindow.WindowSizeInPixels.Width / 4 * 3, mainWindow.WindowSizeInPixels.Height / 2 - NameLabel.ContentSize.Height);
            CreatorLabel.Position = new CCPoint (mainWindow.WindowSizeInPixels.Width / 4 * 3, NameLabel.PositionY - CreatorLabel.ContentSize.Height - 30);
            VersionLabel.Position = new CCPoint (mainWindow.WindowSizeInPixels.Width / 4 * 3, CreatorLabel.PositionY - VersionLabel.ContentSize.Height - 30);
            InfoLabel.Position = new CCPoint (mainWindow.WindowSizeInPixels.Width / 4 * 3, VersionLabel.PositionY - InfoLabel.ContentSize.Height - 30);

            mainLayer.AddChild (PlayButton);
            mainLayer.AddChild (NameLabel);
            mainLayer.AddChild (CreatorLabel);
            mainLayer.AddChild (VersionLabel);
            mainLayer.AddChild (InfoLabel);

            touchListener = new CCEventListenerTouchAllAtOnce ();
            touchListener.OnTouchesEnded = HandleTouchesEnded;
            AddEventListener (touchListener, this);
        }
开发者ID:Nuckal777,项目名称:mapKnight,代码行数:32,代码来源:StartScene.cs

示例4: InitOrientationTest

        private bool InitOrientationTest ()
        {
            bool bRet = false;
            do
            {

                CCSize s = Layer.VisibleBoundsWorldspace.Size;

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

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

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

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

                bRet = true;
            } while (false);

            return bRet;
        }
开发者ID:Kingwl,项目名称:CocosSharp,代码行数:35,代码来源:OrientationTest.cs

示例5: OnEnter

        public override void OnEnter()
        {
            base.OnEnter();

            CCSize s = Layer.VisibleBoundsWorldspace.Size;

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

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

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

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

            menu.Position = (new CCPoint(0, 0));
            item1.Position = (new CCPoint(s.Width / 2 - 100, 30));
            item2.Position = (new CCPoint(s.Width / 2, 30));
            item3.Position = (new CCPoint(s.Width / 2 + 100, 30));
            AddChild(menu, 1);
        }
开发者ID:haithemaraissia,项目名称:CocosSharp,代码行数:30,代码来源:ZwoptexTest.cs

示例6: LabelFNTMultiLine

        public LabelFNTMultiLine()
        {
            CCSize s;

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

            s = label1.ContentSize;

            CCLog.Log("content size label1: {0,0:f2} x {1,0:f2}", s.Width, s.Height);


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

            s = label2.ContentSize;

            CCLog.Log("content size label2: {0,0:f2} x {1,0:f2}", s.Width, s.Height);

            // right
            label3 = new CCLabel("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.Log("content size labe3: {0,0:f2} x {1,0:f2}", s.Width, s.Height);
        }
开发者ID:KevinHeyer,项目名称:CocosSharp,代码行数:32,代码来源:LabelFNTMultiLine.cs

示例7: InitUI

        private void InitUI()
        {
            var title = new CCLabel("冒险与编程", StringManager.GetText("GlobalFont"), 72)
            {
                Position    = new CCPoint(400, 320),
                Color       = CCColor3B.Yellow
            };
            AddChild(title, 100);

            var begin = new CozySampleButton(200, 100, 200, 80)
            {
                // 测试代码
                // Text        = "开始游戏",
                Text        = StringManager.GetText("str3"),
                FontSize    = 24,
                OnClick     = new Action(OnBeginButtonDown),
            };
            AddChild(begin, 100);
            dispatcher.Add(begin);

            var reg = new CozySampleButton(690, 0, 100, 50)
            {
                Text        = "注册帐号",
                FontSize    = 18,
                OnClick     = new Action(OnRegisterButton),
            };
            AddChild(reg, 100);
            dispatcher.Add(reg);

        }
开发者ID:xxy1991,项目名称:cozy,代码行数:30,代码来源:LoginUiLayer.cs

示例8: OnEnter

        public override void OnEnter ()
        {
            base.OnEnter ();

            var origin = Layer.VisibleBoundsWorldspace.Size;

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

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

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


            AddChild (spriteFontNode);

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

            AddChild(menu);
            menu.Position = VisibleBoundsWorldspace.Left();
        }
开发者ID:haithemaraissia,项目名称:CocosSharp,代码行数:34,代码来源:LabelFSTextureView.cs

示例9: IntroLayer

        public IntroLayer()
            : base(CCColor4B.Gray)
        {
            titleLabel = new CCLabel("CocosJuce", "fonts/Roboto-Light-72.fnt");
            frequencyLabel = new CCLabel("", "fonts/Roboto-Light-72.fnt");

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

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

            menu = new CCMenu(onOffSwitch);

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

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

            AddChild(titleLabel);
            AddChild(menu);
            AddChild(frequencyLabel);
            AddChild(frequencyKnob);
        }
开发者ID:altalogix,项目名称:CocosJuce,代码行数:29,代码来源:IntroLayer.cs

示例10: CCControlScene

        public CCControlScene()
		{  
            
            SceneTitleLabel = new CCLabel(" ", "Arial", 12, CCLabelFormat.SpriteFont);
            AddChild(SceneTitleLabel, 1);

		}
开发者ID:haithemaraissia,项目名称:CocosSharp,代码行数:7,代码来源:CCControlScene.cs

示例11: OnEnter

        public override void OnEnter ()
        {
            base.OnEnter ();

            CCSize s = Layer.VisibleBoundsWorldspace.Size;

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

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

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

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

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

            AddChild(menu, 1);
        }
开发者ID:haithemaraissia,项目名称:CocosSharp,代码行数:33,代码来源:MenuLayer.cs

示例12: IntroLayer

        public IntroLayer()
            : base(CCColor4B.White)
        {
            redChair = new CCSprite("images/silla_red.png");
            blueChair = new CCSprite("images/silla_blue.png");
            greenChair = new CCSprite("images/silla_green.png");
            magentaChair = new CCSprite("images/silla_magenta.png");
            cyanChair = new CCSprite("images/silla_cyan.png");
            orangeChair = new CCSprite("images/silla_orange.png");

            sillas.Add(redChair);
            sillas.Add(blueChair);
            sillas.Add(greenChair);
            sillas.Add(magentaChair);
            sillas.Add(cyanChair);
            sillas.Add(orangeChair);

            AddChild(redChair);
            AddChild(blueChair);
            AddChild(greenChair);
            AddChild(magentaChair);
            AddChild(cyanChair);
            AddChild(orangeChair);

            // create and initialize a Label
            label = new CCLabel("Silla Musical", "fonts/MarkerFelt", 22, CCLabelFormat.SpriteFont);

            // add the label as a child to this Layer
            AddChild(label);
        }
开发者ID:sanslash332,项目名称:codename-the-great-and-powerful-phone-party,代码行数:30,代码来源:IntroLayer.cs

示例13: OnEnter

        public override void OnEnter()
        {
            base.OnEnter();

            // ask director the the window size
            var size = VisibleBoundsWorldspace.Size;

            arrowsWidth = (ArrowsMax - ArrowsMin) * size.Width;
            arrowsWidthCenter = arrowsWidth * 0.5f;

            // create and initialize a Label
            label = new CCLabel("Test\nLine\nHeight", "fonts/arial-unicode-26.fnt");
            label.Color = CCColor3B.Red;

            arrowsBar = new CCSprite("Images/arrowsBar");
            arrows = new CCSprite("Images/arrows");
            arrows.Color = CCColor3B.Blue;

            // position the label on the center of the screen
            label.Position = size.Center;

            arrowsBar.Visible = false;

            arrowsBar.ScaleX = (arrowsWidth / arrowsBar.ContentSize.Width);

            arrowsBar.Position = new CCPoint(size.Width / 2.0f, size.Height * 0.15f + arrowsBar.ContentSize.Height * 2.0f);

            snapArrowsToEdge();

            AddChild(label);
            AddChild(arrowsBar);
            AddChild(arrows);

        }
开发者ID:KevinHeyer,项目名称:CocosSharp,代码行数:34,代码来源:LabelFNTLineHeightTest.cs

示例14: LabelSFOldNew

        public LabelSFOldNew()
        {
            // CCLabel SpriteFont
            label1 = new CCLabel("SpriteFont Label Test", "arial", 48, CCLabelFormat.SpriteFont);

            AddChild(label1);

            label2 = new CCLabelTtf("SpriteFont Label Test", "arial", 48);
            label2.Color = CCColor3B.Red;
            label2.AnchorPoint = CCPoint.AnchorMiddle;

            AddChild(label2);

            drawNode = new CCDrawNode();
            AddChild(drawNode);

            var touchListener = new CCEventListenerTouchAllAtOnce();
            touchListener.OnTouchesEnded = (touches, touchEvent) =>
            {
                var location = touches[0].Location;

                if (label1.BoundingBoxTransformedToWorld.ContainsPoint(location))
                    CCLog.Log("Hit");
            };
            AddEventListener(touchListener);

        }
开发者ID:KevinHeyer,项目名称:CocosSharp,代码行数:27,代码来源:LabelSFOldNew.cs

示例15: CreateLabel

        public static CCNode CreateLabel(string text, float size, CCColor3B color, CCColor3B shadowColor)
        {
            var node = new CCNode () {
                AnchorPoint = CCPoint.AnchorMiddle,
            };


            size *= 1.2f;

            var lbl = new CCLabel(text, "fonts/MorrisRoman-Black.ttf", size, CCLabelFormat.SystemFont)
                {
                    Color = color,
                    AnchorPoint = CCPoint.AnchorMiddle,
                };
            lbl.LabelFormat.Alignment = CCTextAlignment.Center;

            node.ContentSize = lbl.ScaledContentSize;
            lbl.Position = node.ContentSize.Center;

            if (shadowColor != CCColor3B.Magenta)
            {
                node.ContentSize = lbl.ContentSize + 2;
                var shadowLbl = new CCLabel (text, "fonts/MorrisRoman-Black.ttf", size, CCLabelFormat.SystemFont) {
                    Color = shadowColor,
                    AnchorPoint = CCPoint.AnchorMiddle,
                    Position = new CCPoint(node.ContentSize.Center.X + 2, node.ContentSize.Center.Y - 2)
                };
                shadowLbl.LabelFormat.Alignment = CCTextAlignment.Center;
                node.AddChild (shadowLbl);
            }
            node.AddChild (lbl);
            return node;
        }
开发者ID:KevinHeyer,项目名称:CocosSharp,代码行数:33,代码来源:LabelSystemFont168.cs


注:本文中的CocosSharp.CCLabel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。