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


C# Text.GetLocalBounds方法代码示例

本文整理汇总了C#中SFML.Graphics.Text.GetLocalBounds方法的典型用法代码示例。如果您正苦于以下问题:C# Text.GetLocalBounds方法的具体用法?C# Text.GetLocalBounds怎么用?C# Text.GetLocalBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SFML.Graphics.Text的用法示例。


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

示例1: CreateTextItem

        private Text CreateTextItem(string text, Font font, uint size, float xPos, float yPos)
        {
            var textItem = new Text(text, font, size);
            textItem.Origin = new Vector2f(
                textItem.GetLocalBounds().Left + textItem.GetLocalBounds().Width / 2,
                textItem.GetLocalBounds().Top + textItem.GetLocalBounds().Height / 2);
            textItem.Position = new Vector2f(xPos, yPos);

            return textItem;
        }
开发者ID:Yozer,项目名称:NanoWar,代码行数:10,代码来源:GameStateResults.cs

示例2: Button

        public Button(string text, Font font, uint fontSize, Vector2f position, float scale = 1f)
        {
            _text = new Text(text, font, fontSize);
            _text.Origin = new Vector2f(
                _text.GetLocalBounds().Left + _text.GetLocalBounds().Width / 2,
                _text.GetLocalBounds().Top + _text.GetLocalBounds().Height);
            _text.Position = position;
            _text.Scale = new Vector2f(scale, scale);

            var increaseAnimation = new ScaleAnimation<Button>(scale, 1f);
            var decreaseAnimation = new ScaleAnimation<Button>(1f, scale);
            _animator.AddAnimation("increase", increaseAnimation, TimeSpan.FromMilliseconds(200));
            _animator.AddAnimation("decrease", decreaseAnimation, TimeSpan.FromMilliseconds(200));
        }
开发者ID:Yozer,项目名称:NanoWar,代码行数:14,代码来源:Button.cs

示例3: GameStateFinish

        public GameStateFinish(string message, bool won)
        {
            _won = won;
            Game.Instance.AudioManager.PauseAllBackground();
            Game.Instance.AudioManager.PlaySound("finish/" + (won ? "win" : "lose") + "_music");

            _background = new Sprite(ResourceManager.Instance["menu/background"] as Texture);

            _text = new Text(message, ResourceManager.Instance["fonts/bebas_neue"] as Font, 50);
            _text.Origin = new Vector2f(_text.GetLocalBounds().Width / 2, _text.GetLocalBounds().Height / 2);
            _text.Position = new Vector2f(Game.Instance.Width / 2, Game.Instance.Height / 2);

            Game.Instance.Window.KeyReleased += WindowOnKeyReleased;
        }
开发者ID:Yozer,项目名称:NanoWar,代码行数:14,代码来源:GameStateFinish.cs

示例4: BigLabeledButtonComponent

        public BigLabeledButtonComponent(Screen screen, Texture buttonTexture, Vector2f position, string text, Color buttonColor, Action onClick)
            : base(screen)
        {
            _buttonTexture = buttonTexture;
            _position = position;
            _buttonColor = buttonColor;
            _selectedColor = new Color(
                (byte)Math.Min(255, (int)_buttonColor.R + 50),
                (byte)Math.Min(255, (int)_buttonColor.G + 50),
                (byte)Math.Min(255, (int)_buttonColor.B + 50),
                255);
            _onClick = onClick;
            _font = ResourceManager.getResource<Font>("immortal_font");

            // Initialize button shape
            _buttonShape = new RectangleShape();
            _buttonShape.Texture = _buttonTexture;
            _buttonShape.Position = position;
            _buttonShape.Size = new Vector2f(_buttonShape.Texture.Size.X, _buttonShape.Texture.Size.Y);
            _buttonShape.FillColor = _buttonColor;

            // Initialize text
            _firstLetter = new Text(text.Substring(0, 1), _font, 72);
            _firstLetter.Position = position + new Vector2f(30, 0);
            _firstLetter.Color = Color.White;
            _firstLetterShadow = new Text(_firstLetter.DisplayedString, _font, 72);
            _firstLetterShadow.Position = _firstLetter.Position + new Vector2f(3, 3);
            _firstLetterShadow.Color = Color.Black;
            _word = new Text(text.Substring(1, text.Length - 1), _font, 48);
            _word.Position = _firstLetter.Position + new Vector2f(_firstLetter.GetLocalBounds().Width + 4, 13);
            _word.Color = Color.White;
            _wordShadow = new Text(_word.DisplayedString, _font, 48);
            _wordShadow.Position = _word.Position + new Vector2f(3, 3);
            _wordShadow.Color = Color.Black;
        }
开发者ID:klutch,项目名称:Loderpit,代码行数:35,代码来源:BigLabeledButtonComponent.cs

示例5: MeasureString

        public Vector2f MeasureString(TextString str)
        {
            Vector2f size = new Vector2f(0f,0f);
            Vector2f curLineSize = new Vector2f(0f, 0f);

            foreach (KeyValuePair<TextStyle, string> s in str.FormatedText)
            {
                if (s.Key == TextStyle.EndLine)
                {
                    size.Y += curLineSize.Y;
                    size.X = curLineSize.X > size.X ? curLineSize.X : size.X;
                    curLineSize = new Vector2f(0f, 0f);
                }
                else
                {
                    Text textSlope = new Text(s.Value, Font, str.CharacterSize);
                    Text.Styles textStyle = Text.Styles.Regular;
                    if ((s.Key & TextStyle.Bold) != 0)
                        textStyle |= Text.Styles.Bold;
                    if( (s.Key & TextStyle.Italic) != 0)
                        textStyle |= Text.Styles.Italic;
                    textSlope.Style = textStyle;
                    FloatRect localBounds = textSlope.GetLocalBounds();

                    Vector2f ssize = new Vector2f(localBounds.Width,localBounds.Height);
                    curLineSize.X += (int)ssize.X;
                    curLineSize.Y = (int)ssize.Y > curLineSize.Y ? (int)ssize.Y : curLineSize.Y;
                }
            }

            size.X = curLineSize.X > size.X ? curLineSize.X : size.X;
            size.Y += curLineSize.Y;
            return size;
        }
开发者ID:Ziple,项目名称:NOubliezPas,代码行数:34,代码来源:Font.cs

示例6: CreateDrawables

 /// <summary>
 /// Настройва текста да се вписва
 /// </summary>
 /// <param name="text"></param>
 private void CreateDrawables(string text)
 {
     drawText = new Text(text, font, 12);
     drawText.Color = foreground;
     FloatRect localBounds = drawText.GetLocalBounds();
     box.Width = (int)localBounds.Width + 10;
     box.Height = (int)localBounds.Height + 6;
 }
开发者ID:3c3,项目名称:GRAPHical_learner,代码行数:12,代码来源:UiLabel.cs

示例7: Initialize

        public void Initialize()
        {
            //To override any of the following, change the variable after calling this function in the constructor
            goldfish = new Font("./assets/goldfish.ttf");
            goldfish.GetTexture(8).Smooth = false;
            nameText = new Text(name, goldfish, 9);
            nameText.Color = Color.Black;
            nameText.Position = new Vector2f(position.X - ((nameText.GetLocalBounds().Width / 4) + 8), position.Y + 17);
            nameText.Style = Text.Styles.Regular;
            healthbarOuter = new RectangleShape(new Vector2f(nameText.GetLocalBounds().Width + 5, nameText.GetLocalBounds().Height + 3));
            healthbar = new RectangleShape(healthbarOuter);
            healthbar.Size = new Vector2f(healthbarOuter.Size.X - 2, healthbarOuter.Size.Y - 2);
            fullHealthPixels = (int)healthbar.Size.X;
            healthbar.FillColor = new Color(153, 255, 153, 170);
            healthbarOuter.FillColor = new Color(0, 0, 0, 120);
            
            orientation = Direction.Down;
            isMoving = false;

            activeWeapon = new Weapon();

            walkingUp = new Animation();
            walkingUp.addFrame(new IntRect(0, 0, 16, 18));
            walkingUp.addFrame(new IntRect(16, 0, 16, 18));
            walkingUp.addFrame(new IntRect(32, 0, 16, 18));

            walkingRight = new Animation();
            walkingRight.addFrame(new IntRect(0, 18, 16, 18));
            walkingRight.addFrame(new IntRect(16, 18, 16, 18));
            walkingRight.addFrame(new IntRect(32, 18, 16, 18));

            walkingDown = new Animation();
            walkingDown.addFrame(new IntRect(0, 18 * 2, 16, 18));
            walkingDown.addFrame(new IntRect(16, 18 * 2, 16, 18));
            walkingDown.addFrame(new IntRect(32, 18 * 2, 16, 18));

            walkingLeft = new Animation();
            walkingLeft.addFrame(new IntRect(0, 18 * 3, 16, 18));
            walkingLeft.addFrame(new IntRect(16, 18 * 3, 16, 18));
            walkingLeft.addFrame(new IntRect(32, 18 * 3, 16, 18));

            boundingbox = new IntRect((int)position.X, (int)position.Y, 16, 16);
        }
开发者ID:riordanp,项目名称:panjin,代码行数:43,代码来源:Actor.cs

示例8: UnitCell

        public UnitCell(Cell targetCell, Cell sourceCell, int units, PlayerInstance player)
        {
            TargetCell = targetCell;
            SourceCell = sourceCell;
            Units = UnitsLeft = units;
            _currentVelocity = Velocity;

            string colorName = null;
            if (SourceCell.Player.Color.R == 255 && SourceCell.Player.Color.G == 0 && SourceCell.Player.Color.B == 0)
            {
                colorName = "red";
            }
            else if (SourceCell.Player.Color.R == 0 && SourceCell.Player.Color.G == 255 && SourceCell.Player.Color.B == 0)
            {
                colorName = "green";
            }
            else if (SourceCell.Player.Color.R == 0 && SourceCell.Player.Color.G == 0
                     && SourceCell.Player.Color.B == 255)
            {
                colorName = "blue";
            }

            _sprite = new Sprite(ResourceManager.Instance["game/unit_cell_" + colorName] as Texture);

            _text = new Text(units.ToString(), ResourceManager.Instance["fonts/verdana"] as Font, FontSize);
            _text.Origin = new Vector2f(
                _text.GetLocalBounds().Left + _text.GetLocalBounds().Width / 2,
                _text.GetLocalBounds().Top);

            _particleSystem = new ParticleSystem(ResourceManager.Instance["game/particle"] as Texture);

            var scale = 0.5f + Units * 0.0125f;
            if (scale >= 1f)
            {
                scale = 1f;
            }

            Scale = _initialScale = new Vector2f(scale, scale);

            Radius = _sprite.GetGlobalBounds().Height / 2;
            _sprite.Origin = new Vector2f(_sprite.GetLocalBounds().Width / 2, _sprite.GetLocalBounds().Height / 2);
            SourcePlayer = player;
        }
开发者ID:Yozer,项目名称:NanoWar,代码行数:43,代码来源:UnitCell.cs

示例9: SelectorButton

        public SelectorButton(SelectorPannel parent, Types type, Vector2f offset, Vector2f dimensions, string name, Color c, Texture t = null)
        {
            this.parent = parent;
            this.Type = type;
            this.offset = offset;
            this.positionBox = new Rectangle(parent.PositionBox.x + offset.X, parent.PositionBox.y + offset.Y, dimensions.X, dimensions.Y);
            updateBlockParamers();
            this.text = new Text(name, Game1.plainFont);
            text.Color = Color.Black;
            text.CharacterSize = 24;
            text.Origin = new Vector2f(text.GetLocalBounds().Left, text.GetLocalBounds().Top);
            setTextPosition();

            this.outlineLight = new Color(255, 255, 255, 0);
            this.outlineDark = new Color(parent.Color.R, parent.Color.G, parent.Color.B, 220);
            this.currentOutline = outlineDark;
            this.drawColor = c;
            if (t != null)
                sprite = new Sprite(t);
        }
开发者ID:Raptor2277,项目名称:CubePlatformer,代码行数:20,代码来源:SelectorButtons.cs

示例10: drawString

        public static void drawString(Font font, String message, Vector2f position, Color color, float scale, bool centered)
        {
            Text text = new Text(message, font);
            text.Scale = new Vector2f(scale, scale);
            text.Position = position;// clientPlayer.position;
            text.Color = color;
            if (centered)
                text.Position = new Vector2f(text.Position.X - ((text.GetLocalBounds().Width * scale) / 2), text.Position.Y);

            Game.window.Draw(text);
        }
开发者ID:libjared,项目名称:jaunt,代码行数:11,代码来源:Render.cs

示例11: SplashScreenState

        public SplashScreenState()
        {
            //Create the orb
            splashSprite = new Sprite(new Texture("Assets/Textures/splashOrb.png") { Smooth = true });
            splashSprite.Color = renderColor;
            splashSprite.Origin = splashSprite.Texture.Center();
            splashSprite.Position = new SFML.System.Vector2f(Program.Window.Size.X / 2, (Program.Window.Size.Y / 5) * 3);

            //Create the title label
            titleText = new Text("ORBS", new Font("Assets/Fonts/Base.ttf"), 140);
            titleText.Color = renderColor;
            titleText.Position = new Vector2f(Program.Window.Size.X / 2 - titleText.GetLocalBounds().Width / 2, 100);
        }
开发者ID:Blezzing,项目名称:Orbs,代码行数:13,代码来源:SplashScreenState.cs

示例12: SetupButtonAdditional

 protected override void SetupButtonAdditional(int i, DisplayObject button, RectangleShape button_back, bool pickable)
 {
     // current level
     Text currentLevel = new Text("", Game.TidyHand, 45);
     if (pickable)
         currentLevel.DisplayedString = Game.Player.GetUpgradeValue(i, Game.Player.UpgradeLevels[i]) + " -> " + Game.Player.GetUpgradeValue(i, Game.Player.UpgradeLevels[i] + 1);
     else
         currentLevel.DisplayedString = Game.Player.GetUpgradeValue(i, Game.Player.UpgradeLevels[i]) + " (MAX)";
     FloatRect currentLevelRect = currentLevel.GetLocalBounds();
     currentLevel.Origin = new Vector2f(currentLevelRect.Width / 2.0f, 0);
     currentLevel.Position = new Vector2f(button_back.Size.X / 2, 120);
     currentLevel.Color = new Color(255, 255, 255, (byte)(pickable ? 255 : 120));
     button.AddChild(currentLevel);
 }
开发者ID:Torrunt,项目名称:SingleSwitchGame,代码行数:14,代码来源:UpgradeMenu.cs

示例13: MainMenuState

        public MainMenuState()
        {
            Font menuFont = new Font("Assets/Fonts/Base.ttf");

            title = new Text("ORBS", menuFont, 140);
            title.Color = new Color(200, 200, 255);
            title.Position = new SFML.System.Vector2f(Program.Window.Size.X / 2 - title.GetLocalBounds().Width / 2, 100);

            List<Tuple<String,Action>> items = new List<Tuple<String, Action>>();
            items.Add(new Tuple<string, Action>("Play",     () => { Program.StateManager.EnterState(new ExploringState()); }    ));
            items.Add(new Tuple<string, Action>("Options",  () => { Program.IsFpsRendering = !Program.IsFpsRendering; }         ));
            items.Add(new Tuple<string, Action>("Help",     () => { }                                                           ));
            items.Add(new Tuple<string, Action>("Credits",  () => { Program.StateManager.LeaveCurrentState(); }                 ));
            items.Add(new Tuple<string, Action>("Exit",     () => { Program.Window.Close(); }                                   ));

            menu = new Menu(items, menuFont, 60, new Vector2f(Program.Window.Size.X / 2, 350),700);
        }
开发者ID:Blezzing,项目名称:Orbs,代码行数:17,代码来源:MainMenuState.cs

示例14: MessageFade

        public MessageFade(Game game, string msg, uint fontSize, Vector2f position, Action callBack = null, double showTime = 1500, bool center = true)
            : base(game)
        {
            Text = new Text(msg, Game.TidyHand, fontSize);
            Text.Color = new Color(255, 255, 255, 0);
            FloatRect textRect = Text.GetLocalBounds();
            if (center)
                Text.Origin = new Vector2f(textRect.Left + textRect.Width / 2.0f, textRect.Top + textRect.Height / 2.0f);

            AddChild(Text);
            Position = position;

            ShowTimer = new Timer(showTime);
            ShowTimer.AutoReset = false;
            ShowTimer.Elapsed += ShowTimerHandler;

            CallBack = callBack;
        }
开发者ID:Torrunt,项目名称:SingleSwitchGame,代码行数:18,代码来源:MessageFade.cs

示例15: TextBox

 public TextBox(WindowManager _WM, int _X, int _Y, int _SizeX,int _SizeY,bool _AllowInput)
     : base(_WM, _X, _Y, _SizeX, _SizeY)
 {
     localx = _X;
     localy = _Y;
     AllowInput = _AllowInput;
     BoxText = new Text("", _WM.font,15);
     BackPlate = new RectangleShape();
     Cursor = new RectangleShape();
     Cursor.Size = new Vector2f(1, BoxText.GetLocalBounds().Height*2);
     Cursor.FillColor = Color.Green;
     //BoxText.Position = new Vector2f(_X, _Y);
     SetSize(_SizeX, 15*_SizeY);
     BackPlate.Size = new Vector2f(BoundingBox.Width, BoundingBox.Height);
     //BackPlate.Position = new Vector2f(BoxText.GetLocalBounds().Left, BoxText.GetLocalBounds().Top);
     //BackPlate.Size = new Vector2f((int)BoxText.GetGlobalBounds().Width, (int)BoxText.GetGlobalBounds().Height * 2);
     BackPlate.FillColor = Color.Magenta;
 }
开发者ID:Tricon2-Elf,项目名称:SpaceHybridTest,代码行数:18,代码来源:TextBox.cs


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