DeenGames.Utils.Tower.Core.TowerScreen.AddSprite C# (CSharp) Method

AddSprite() public method

Adds a sprite to our internal collection, so we don't have to clean it up manually later.
public AddSprite ( string texture ) : Sprite
texture string
return FlatRedBall.Sprite
        public Sprite AddSprite(string texture)
        {
            Sprite s = SpriteManager.AddSprite(texture);
            s.PixelSize = 0.5f;
            this.ManageForGarbageCollection(s);
            return s;
        }

Usage Example

Example #1
0
        public void InitializeToScreen(TowerScreen screen)
        {
            _atomNameText = screen.AddText(string.Empty);
            _atomValenceText = screen.AddText(string.Empty);
            _atomElectronegativityText = screen.AddText(string.Empty);
            _atomDescription = screen.AddText(string.Empty);
            _background = screen.AddSprite("Content/message-panel.png");

            _atomNameText.Y = 70;
            _atomValenceText.Y = _atomNameText.Y;
            _atomElectronegativityText.Y = _atomNameText.Y;
            _atomDescription.Y = _atomNameText.Y - 20;

            _atomNameText.Scale = 18;
            _atomValenceText.Scale = 18;
            _atomElectronegativityText.Scale = 18;
            _atomDescription.Scale = 18;

            _atomNameText.HorizontalAlignment = FlatRedBall.Graphics.HorizontalAlignment.Left;
            _atomNameText.X = -175;

            _atomDescription.HorizontalAlignment = FlatRedBall.Graphics.HorizontalAlignment.Left;
            _atomDescription.X = _atomNameText.X;
            _atomDescription.VerticalAlignment = FlatRedBall.Graphics.VerticalAlignment.Top;

            _atomElectronegativityText.HorizontalAlignment = FlatRedBall.Graphics.HorizontalAlignment.Right;
            _atomElectronegativityText.X = (this._background.Texture.Width / 2) - 25;

            // Climb on top of everything
            this._background.Z = 1;
            this._atomDescription.Z = 2;
            this._atomElectronegativityText.Z = 2;
            this._atomNameText.Z = 2;
            this._atomValenceText.Z = 2;

            this.Hide();
        }