Class FrameRateCounter
- Namespace
- BSGameLib.Game.Components
- Assembly
- BSGameLib.Game.dll
Shows the frames drawn per second (FPS) and updates per second (UPS) as text, refreshed once a second.
public class FrameRateCounter : DrawableComponent, IUpdateable, IEquatable<IUpdateable>, IDrawable, IIdentifiable<Guid>, IEquatable<IDrawable>
- Inheritance
-
FrameRateCounter
- Implements
- Inherited Members
Remarks
The text is drawn twice: first the shadow copy at Position2 in Color2, then the main copy at Position in Color.
Constructors
FrameRateCounter(IContentManager, IFont, Vector2, Color, Color, IRenderContextFactory, ITextRenderer)
Creates the counter. It draws at position in color, with a shadow in color2 one pixel right and down. Drawing needs renderContextFactory.
public FrameRateCounter(IContentManager contentManager, IFont font, Vector2 position, Color color, Color color2, IRenderContextFactory renderContextFactory, ITextRenderer textRenderer)
Parameters
contentManagerIContentManagerfontIFontpositionVector2colorColorcolor2ColorrenderContextFactoryIRenderContextFactorytextRendererITextRenderer
Exceptions
- ArgumentNullException
textRendereris null.
Properties
Color
The colour of the main copy of the text.
public Color Color { get; set; }
Property Value
Color2
The colour of the shadow copy of the text.
public Color Color2 { get; set; }
Property Value
Position
Where the main copy of the text is drawn.
public Vector2 Position { get; set; }
Property Value
Position2
Where the shadow copy of the text is drawn. The constructor sets it one pixel right and down of Position; changing Position does not move it.
public Vector2 Position2 { get; set; }
Property Value
ShowFps
Whether the text is drawn. The rates are counted either way.
public bool ShowFps { get; set; }
Property Value
Methods
Draw(IGameTime)
Counts a draw, and once a second makes the count the FPS shown. Then draws the text if ShowFps is true.
public override void Draw(IGameTime gameTime)
Parameters
gameTimeIGameTime
Exceptions
- InvalidOperationException
No render context factory was given to the constructor.
Update(IGameTime)
Counts an update. Once a second, the count becomes the UPS shown.
public override void Update(IGameTime gameTime)
Parameters
gameTimeIGameTime