Class Tween
- Namespace
- FriedSynapse.FlowEnt
A tween is a simple interpolation from 0 to 1 which has several options and events attached. For more information please go to https://flowent.friedsynapse.com/tween
public sealed class Tween : AbstractAnimation, IControllable
- Inheritance
-
Tween
- Implements
- Inherited Members
- Extension Methods
Constructors
Tween(TweenOptions)
Creates a new tween using the options provided.
public Tween(TweenOptions options)
Parameters
options
TweenOptions
Tween(float, bool)
Creates a new tween.
public Tween(float time = 1, bool autoStart = false)
Parameters
time
floatThe amount of time for this tween in seconds.
autoStart
boolWhether the tween should start automatically or not.
Properties
Easing
public IEasing Easing { get; }
Property Value
LoopType
public LoopType LoopType { get; }
Property Value
Time
public float Time { get; }
Property Value
Methods
Apply(params AbstractTweenMotion[])
Applies all the motions to the current tween.
public Tween Apply(params AbstractTweenMotion[] motions)
Parameters
motions
AbstractTweenMotion[]
Returns
Apply(IEnumerable<AbstractTweenMotion>)
Applies all the motions to the current tween.
public Tween Apply(IEnumerable<AbstractTweenMotion> motions)
Parameters
motions
IEnumerable<AbstractTweenMotion>
Returns
Conditional(Func<bool>, Action<Tween>)
Executes the onConditionTrue
if condition
returns true.
public Tween Conditional(Func<bool> condition, Action<Tween> onConditionTrue)
Parameters
Returns
ForAll<TItem>(IEnumerable<TItem>)
Creates a scope for the object so you can add motions designed specifically for that enumeration of objects.
public TweenMotionProxyArray<TItem> ForAll<TItem>(IEnumerable<TItem> elements)
Parameters
elements
IEnumerable<TItem>
Returns
- TweenMotionProxyArray<TItem>
Type Parameters
TItem
For<TItem>(TItem)
Creates a scope for the object so you can add motions designed specifically for that object.
public TweenMotionProxy<TItem> For<TItem>(TItem element)
Parameters
element
TItem
Returns
- TweenMotionProxy<TItem>
Type Parameters
TItem
For<TItem>(params TItem[])
Creates a scope for the object so you can add motions designed specifically for that array of objects.
public TweenMotionProxyArray<TItem> For<TItem>(params TItem[] elements)
Parameters
elements
TItem[]
Returns
- TweenMotionProxyArray<TItem>
Type Parameters
TItem
OnCompleted(Action)
Adds an event called when the animation has completed.
public Tween OnCompleted(Action callback)
Parameters
callback
ActionThe event.
Returns
OnCompleting(Action)
Adds an event called when the animation is completing.
public Tween OnCompleting(Action callback)
Parameters
callback
ActionThe event.
Returns
OnLoopCompleted(Action<int?>)
Adds an event called when the animation loop has completed.
public Tween OnLoopCompleted(Action<int?> callback)
Parameters
callback
Action<int?>The event. The parameter represents the number of loops left. If there are infinite loops it'll send a null param.
Returns
OnLoopStarted(Action<int?>)
Adds an event called when the animation loop has started.
public Tween OnLoopStarted(Action<int?> callback)
Parameters
callback
Action<int?>The event. The parameter represents the number of loops left. If there are infinite loops it'll send a null param.
Returns
OnStarted(Action)
Adds an event called when the animation has started.
public Tween OnStarted(Action callback)
Parameters
callback
ActionThe event.
Returns
OnStarting(Action)
Adds an event called when the animation is starting.
public Tween OnStarting(Action callback)
Parameters
callback
ActionThe event.
Returns
OnUpdated(Action<float>)
Adds an event called when the animation has updated.
public Tween OnUpdated(Action<float> callback)
Parameters
Returns
OnUpdating(Action<float>)
Adds an event called when the animation is updating.
public Tween OnUpdating(Action<float> callback)
Parameters
Returns
Pause()
Pauses the animation.
public Tween Pause()
Returns
Reset()
Resets the animation so in can be replayed.
public Tween Reset()
Returns
Exceptions
- AnimationException
If the animation is not finished.
- AnimationException
If the tween is not finished.
ResetInternal()
protected override void ResetInternal()
Resume()
Resumes the animation.
public Tween Resume()
Returns
SetAutoStart(bool)
Sets whether this animation should auto-start or not.
public Tween SetAutoStart(bool autoStart)
Parameters
autoStart
bool
Returns
Remarks
Auto-start will be slower than a true-start. See more at https://flowent.friedsynapse.com/tips#h.s5cucrg5qyjc
SetDelay(float)
Sets the amount of time in seconds that you want to delay when this animation is started.
public Tween SetDelay(float time)
Parameters
time
float
Returns
SetDelayUntil(Func<bool>)
Sets the callback that holds the starting of the animation.
public Tween SetDelayUntil(Func<bool> callback)
Parameters
Returns
SetEasing(AnimationCurve, bool)
Sets the easing of the tween using an animation curve.
public Tween SetEasing(AnimationCurve animationCurve, bool reverse = false)
Parameters
animationCurve
AnimationCurvereverse
boolWill apply a reverse on the easing.
Returns
SetEasing(Easing, bool)
Sets the easing of the tween using predefined values.
public Tween SetEasing(Easing easing, bool reverse = false)
Parameters
Returns
SetEasing(IEasing, bool)
Sets the easing of the tween.
public Tween SetEasing(IEasing easing, bool reverse = false)
Parameters
Returns
SetEasing(Func<float, float>, bool)
Sets the easing of the tween using a FunctionEasing.
public Tween SetEasing(Func<float, float> easing, bool reverse = false)
Parameters
Returns
SetEvents(TweenEvents)
Sets all the events for this tween.
public Tween SetEvents(TweenEvents events)
Parameters
events
TweenEvents
Returns
SetEvents(Func<TweenEvents, TweenEvents>)
Creates a builder for events and then sets all the events for this tween.
public Tween SetEvents(Func<TweenEvents, TweenEvents> eventsBuilder)
Parameters
eventsBuilder
Func<TweenEvents, TweenEvents>
Returns
SetLoopCount(int?)
Sets the amount of loops you want this animation to have. If you want infinite loops pass a null value.
public Tween SetLoopCount(int? loopCount)
Parameters
loopCount
int?
Returns
Remarks
Flows only have reset loop types.
SetLoopType(LoopType)
Sets the loop type of the tween.
public Tween SetLoopType(LoopType loopType)
Parameters
loopType
LoopType
Returns
SetName(string)
Sets the name of the animation.
public Tween SetName(string name)
Parameters
name
string
Returns
SetOptions(TweenOptions)
Sets all the options for this tween.
public Tween SetOptions(TweenOptions options)
Parameters
options
TweenOptions
Returns
SetOptions(Func<TweenOptions, TweenOptions>)
Creates a builder for options and then sets all the options for this tween.
public Tween SetOptions(Func<TweenOptions, TweenOptions> optionsBuilder)
Parameters
optionsBuilder
Func<TweenOptions, TweenOptions>
Returns
SetSkipFrames(int)
Sets the amount of frames you want to skip at when this animation is started.
public Tween SetSkipFrames(int frames)
Parameters
frames
int
Returns
SetTime(float)
Sets the amount of time in seconds that this tween will last.
public Tween SetTime(float time)
Parameters
time
float
Returns
SetTimeScale(float)
Sets the time scale for the current animation.
public Tween SetTimeScale(float timeScale)
Parameters
timeScale
float
Returns
SetUpdateType(UpdateType)
Sets the update type for the animation.
public Tween SetUpdateType(UpdateType updateType)
Parameters
updateType
UpdateType
Returns
Start()
Starts the animation.
public Tween Start()
Returns
Exceptions
- AnimationException
If the tween has already started.
StartAsync(CancellationToken?)
Starts the animation async(you can await this till the animation finishes).
public Task<Tween> StartAsync(CancellationToken? token = null)
Parameters
token
CancellationToken?The cancellation doesn't cancel the task, but rather terminates the animation. The task will be completed
Returns
Exceptions
- AnimationException
If the tween has already started.
Stop(bool)
Stops the animation.
public Tween Stop(bool triggerOnCompleted = false)
Parameters
triggerOnCompleted
boolIf set to true will trigger the "OnCompleted" event on the animation