feat: TextBehaviour
This commit is contained in:
		
							
								
								
									
										21
									
								
								Game/Behaviours/TextBehaviour.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								Game/Behaviours/TextBehaviour.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,21 @@
 | 
			
		||||
using Microsoft.Xna.Framework;
 | 
			
		||||
using Microsoft.Xna.Framework.Graphics;
 | 
			
		||||
using Syntriax.Engine.Core;
 | 
			
		||||
using Syntriax.Engine.Core.Abstract;
 | 
			
		||||
 | 
			
		||||
namespace Pong.Behaviours;
 | 
			
		||||
 | 
			
		||||
public class TextBehaviour : BehaviourOverride, IDisplayable
 | 
			
		||||
{
 | 
			
		||||
    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);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user