Engine-Pong/Game/Behaviours/TextBehaviour.cs

26 lines
775 B
C#
Raw Normal View History

2024-01-28 15:44:33 +03:00
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
2024-01-30 12:43:30 +03:00
2024-01-28 15:44:33 +03:00
using Syntriax.Engine.Core;
using Syntriax.Engine.Core.Abstract;
namespace Pong.Behaviours;
public class TextBehaviour : BehaviourOverride, IDisplayableSprite
2024-01-28 15:44:33 +03:00
{
public TextBehaviour() { }
public TextBehaviour(SpriteFont font) => Font = font;
2024-01-28 15:44:33 +03:00
public SpriteFont? Font { get; set; } = null;
public int Size { get; set; } = 16;
public string Text { get; set; } = string.Empty;
public void Draw(SpriteBatch spriteBatch)
{
if (!IsActive || Font is null)
return;
spriteBatch.DrawString(Font, Text, Transform.Position.ToDisplayVector2(), Color.White, Transform.Rotation, Vector2.One * .5f, Transform.Scale.Magnitude, SpriteEffects.None, 0f);
}
}