public override void Update(GameTime gameTime) { base.Update(gameTime); for (int i = _activeSprites.Count - 1; i >= 0; i--) { TextSprite doneSprite = _activeSprites[i]; if (!doneSprite.Enabled) { _activeSprites.RemoveAt(i); _inactiveSprites.Add(doneSprite); } } foreach (var item in _activeSprites) { item.Update(gameTime); } }
private TextSprite GetSprite(Vector2 position, string text, Color color, float beginScale = 1, float endScale = 1, float msLifeLength = 400) { TextSprite sprite = null; if (_inactiveSprites.Count > 0) { sprite = _inactiveSprites[0]; _inactiveSprites.RemoveAt(0); sprite.Texture = GetTexture(text); sprite.Position = position; sprite.Enabled = true; sprite.Opacity = 1; sprite.Color = color; sprite.BeginScale = beginScale; sprite.EndScale = endScale; sprite.OriginalLifeInMiliseconds = msLifeLength; sprite.Reset(); } else { sprite = new TextSprite(Game, GetTexture(text), position, _spriteBatch, color, beginScale, endScale, msLifeLength); } return(sprite); }
public void AddTextSprite(Vector2 position, string text, Color color, float beginScale = 1, float endScale = 1, float msLifeLength = 400) { TextSprite sprite = GetSprite(position, text, color, beginScale, endScale, msLifeLength); _activeSprites.Add(sprite); }
public void AddTextSprite(Vector2 position, string text) { TextSprite sprite = GetSprite(position, text, _textColor); _activeSprites.Add(sprite); }