Class UiAnimation
A ui animation is a simple timed event that an Element in a UiSystem can use to play a visual or other type of animation. To use ui animations, you can use PlayAnimation(UiAnimation), or one of the built-in style properties like MouseEnterAnimation or MouseExitAnimation.
public class UiAnimation : GenericDataHolder, IGenericDataHolder
- Inheritance
-
UiAnimation
- Implements
- Inherited Members
Constructors
UiAnimation(double, AnimationFunction)
Creates a new ui animation with the given settings.
public UiAnimation(double seconds, UiAnimation.AnimationFunction function)
Parameters
seconds
doubleThe amount of seconds that this ui animation should play for.
function
UiAnimation.AnimationFunctionThe UiAnimation.AnimationFunction that is invoked every Update(Element, GameTime).
UiAnimation(TimeSpan, AnimationFunction)
Creates a new ui animation with the given settings.
public UiAnimation(TimeSpan totalTime, UiAnimation.AnimationFunction function)
Parameters
totalTime
TimeSpanThe TotalTime that this ui animation should play for.
function
UiAnimation.AnimationFunctionThe UiAnimation.AnimationFunction that is invoked every Update(Element, GameTime).
Fields
Finished
An event that is raised when this ui animation is stopped or finished through OnFinished(Element).
public Action<UiAnimation, Element> Finished
Field Value
Function
The UiAnimation.AnimationFunction that is invoked every Update(Element, GameTime).
public readonly UiAnimation.AnimationFunction Function
Field Value
Started
An event that is raised when this ui animation is (re)started in Update(Element, GameTime).
public Action<UiAnimation, Element> Started
Field Value
TotalTime
The total time that this ui animation plays for.
public readonly TimeSpan TotalTime
Field Value
Properties
CurrentTime
The current time that this ui animation has been playing for, out of the TotalTime.
public TimeSpan CurrentTime { get; }
Property Value
Methods
OnFinished(Element)
Causes this ui animation's Finished event to be raised, and sets the CurrentTime to Zero. This allows the animation to play from the start again. This method is invoked automatically when Update(Element, GameTime) returns true in Update(GameTime), as well as in StopAnimation(UiAnimation).
public virtual void OnFinished(Element element)
Parameters
element
Element
Update(Element, GameTime)
Updates this ui animation, invoking its Started event if necessary, increasing its CurrentTime and invoking its Function. This method is called by an Element in Update(GameTime).
public virtual bool Update(Element element, GameTime time)
Parameters
element
ElementThe element that this ui animation is attached to.
time
GameTimeThe game's current time.
Returns
- bool
Whether this animation is ready to finish, that is, if its CurrentTime is greater than or equal to its TotalTime.