41 lines
817 B
C#
41 lines
817 B
C#
using System.Numerics;
|
|
using DaggerFramework;
|
|
using DaggerFramework.SceneGraph;
|
|
|
|
public class UiLayer : EntityLayer
|
|
{
|
|
protected override void OnStart()
|
|
{
|
|
base.OnStart();
|
|
|
|
GetResources();
|
|
CreateAndAddEntities();
|
|
}
|
|
|
|
protected override void OnUpdate(double dt)
|
|
{
|
|
base.OnUpdate(dt);
|
|
|
|
_fpsText.Text = $"{MathF.Round(1 / (float)dt)} FPS";
|
|
}
|
|
|
|
private void CreateAndAddEntities()
|
|
{
|
|
_fpsText = new Text2d()
|
|
{
|
|
Font = _defaultFont,
|
|
Position = Vector2.One * 16,
|
|
FontSize = 20
|
|
};
|
|
|
|
AddEntity(_fpsText);
|
|
}
|
|
|
|
private void GetResources()
|
|
{
|
|
ResourceManager.TryGetResource("inter_regular", out _defaultFont);
|
|
}
|
|
|
|
private Text2d _fpsText;
|
|
private Font _defaultFont;
|
|
} |