Table of Contents

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

contentManager IContentManager
font IFont
position Vector2
color Color
color2 Color
renderContextFactory IRenderContextFactory
textRenderer ITextRenderer

Exceptions

ArgumentNullException

textRenderer is null.

Properties

Color

The colour of the main copy of the text.

public Color Color { get; set; }

Property Value

Color

Color2

The colour of the shadow copy of the text.

public Color Color2 { get; set; }

Property Value

Color

Position

Where the main copy of the text is drawn.

public Vector2 Position { get; set; }

Property Value

Vector2

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

Vector2

ShowFps

Whether the text is drawn. The rates are counted either way.

public bool ShowFps { get; set; }

Property Value

bool

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

gameTime IGameTime

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

gameTime IGameTime