/// <summary> /// Adds new floating text. Destruction is automatic /// </summary> /// <param name="msg">Message to be shown.</param> /// <param name="pos">Position of center of the message.</param> /// <param name="c">Message colour.</param> public void Add(string msg, Vector2 pos, Color c) { FloatTextInstance ft = new FloatTextInstance(); ft.message = msg; ft.position = pos; ft.color = c; ft.livingTime = 0.0f; ft.origin = font.MeasureString(ft.message) / 2; collection.AddFirst(ft); }
/// <returns>False if dead, true if alive</returns> private bool Update(FloatTextInstance inst) { if (inst.livingTime++ >= TIME_TO_LIVE) return false; inst.position += velocity; inst.color.A -= (byte)(255 / TIME_TO_LIVE); return true; }
private void Draw(FloatTextInstance inst) { spriteBatch.DrawString(font, inst.message, inst.position, inst.color, 0.0f, inst.origin, 1f, SpriteEffects.None, 0); }