Tweening
Inbetweening, or just tweening for short, allows you to generate values for position, size, color, opacity, etc in intermediate frames giving the illusion of animation.
Installation
MonoGame.Extended.Tweening
is distributed via NuGet packages. You can add the NuGet package to your C# project through your IDE of choice (Visual Studio, Xamarin Studio, Rider, etc) or through the Command Line Interface (CLI) using the dotnet command.
Example
The assets used in the example don't have any unique assets to download.
Usage
We start by including the Tweening
namespace.
Next, we declare a class with a property we want to tween.
Next, we instantiate an instance of the Tweener and our class.
Then we order the Tweener
to tween the position.
The Tween method requires a target object and an expression that refers to a property of that object.
Next, we add the Tweener
to the update loop,
And last but not least we draw.
Easing functions
EasingFunctions
calculate a value given a percentage of completeness.
In the example EasingFunctions.Linear
was used. Below is a visual representation of the other EasingFunctions