Table of Contents

Class GameTimeExtensions

Namespace
Thunder.UnitsNET.Vectors.MonoGame
Assembly
Thunder.UnitsNET.Vectors.MonoGame.dll

Extension methods for Microsoft.Xna.Framework.GameTime that bridge MonoGame's time model to UnitsNet's UnitsNet.Duration type.

public static class GameTimeExtensions
Inheritance
GameTimeExtensions
Inherited Members

Methods

ElapsedAsDuration(GameTime)

Returns the elapsed game time as a UnitsNet UnitsNet.Duration.

public static Duration ElapsedAsDuration(this GameTime gameTime)

Parameters

gameTime GameTime

The current game time provided by MonoGame's Update method.

Returns

Duration

A UnitsNet.Duration equal to gameTime.ElapsedGameTime.TotalSeconds. Sub-millisecond precision is preserved because TotalSeconds returns a double.

Examples

var gameTime = new GameTime(TimeSpan.Zero, TimeSpan.FromMilliseconds(16));
Duration dt = gameTime.ElapsedAsDuration();

Remarks

Eliminates the boilerplate Duration.FromSeconds(gameTime.ElapsedGameTime.TotalSeconds) at every physics or movement update call site.

v0.7.0 ▼