Class Animation
- Namespace
- Fantas
- Assembly
- Fantas.dll
Animation class (Move, Scale, Rotate, Fade...)
public sealed class Animation
- Inheritance
-
Animation
- Inherited Members
Properties
Duration
Duration to complete the animation. WARNING: Some animation might ignore the change to this value after the animation is created
public TimeSpan Duration { get; set; }
Property Value
DurationSeconds
Duration to complete the animation. WARNING: Some animation might ignore the change to this value after the animation is created
public double DurationSeconds { get; set; }
Property Value
ReversedAnimation
Create a reversed animation WARNING: Fade, and Texture animation won't have reverse You have to manually create FadeIn/FadeOut reverses
public Animation ReversedAnimation { get; }
Property Value
Speed
Speed of animation
public float Speed { get; set; }
Property Value
TimingFunction
Delegate used to customize the timing
public AnimationTimingFunction TimingFunction { get; set; }
Property Value
TimingMode
Animation timing mode (linear, ease-in ..)
public AnimationTimingMode TimingMode { get; set; }
Property Value
Methods
Animate(Texture[], double)
Animate the sprite texture
public static Animation Animate(Texture[] textures, double timePerFrame)
Parameters
Returns
- Animation
Animation object that can be executed on a SpriteNode
Animate(Texture[], double, bool, bool)
Animate the sprite texture
public static Animation Animate(Texture[] textures, double timePerFrame, bool resize, bool restore)
Parameters
textures
Texture[]list of textures of animation
timePerFrame
doubleTime per Frame (in seconds)
resize
boolresize SpriteNode according to texture
restore
boolRestore SpriteNode to original texture when animation is finished or removed
Returns
- Animation
Animation object that can be executed on a SpriteNode
Colorize(Color, float, double)
Animate sprite tint color
public static Animation Colorize(Color color, float colorBlendFactor, double duration)
Parameters
color
ColorFinal tint color of Sprite
colorBlendFactor
floatFinal color blend factor
duration
doubleDuration in seconds
Returns
- Animation
Animation object that can be executed on a SpriteNode
Colorize(Color, float, TimeSpan)
Animate sprite tint color
public static Animation Colorize(Color color, float colorBlendFactor, TimeSpan duration)
Parameters
color
ColorFinal tint color of Sprite
colorBlendFactor
floatFinal color blend factor
duration
TimeSpanDuration in seconds
Returns
- Animation
Animation object that can be executed on a SpriteNode
Colorize(float, double)
Animate sprite tint color
public static Animation Colorize(float colorBlendFactor, double duration)
Parameters
Returns
- Animation
Animation object that can be executed on a SpriteNode
Colorize(float, TimeSpan)
Animate sprite tint color
public static Animation Colorize(float colorBlendFactor, TimeSpan duration)
Parameters
Returns
- Animation
Animation object that can be executed on a SpriteNode
Custom(double, Action<Node, float>)
Execute the callback over the execution of animation
public static Animation Custom(double duration, Action<Node, float> callback)
Parameters
duration
doubleDuration in seconds
callback
Action<Node, float>Called along the execution of the animation
Returns
- Animation
Custom animation object
Custom(TimeSpan, Action<Node, float>)
Execute the callback over the execution of animation
public static Animation Custom(TimeSpan duration, Action<Node, float> callback)
Parameters
duration
TimeSpanDuration in seconds
callback
Action<Node, float>Called along the execution of the animation
Returns
- Animation
Custom animation object
Equals(object)
Equals(obj)
public override bool Equals(object obj)
Parameters
obj
object
Returns
FadeAlphaBy(float, double)
Change the alpha of node
public static Animation FadeAlphaBy(float delta, double duration)
Parameters
Returns
- Animation
Animation object that can be executed on a Node
FadeAlphaBy(float, TimeSpan)
Change the alpha of node
public static Animation FadeAlphaBy(float delta, TimeSpan duration)
Parameters
Returns
- Animation
Animation object that can be executed on a Node
FadeAlphaTo(float, double)
Animate new alpha of node
public static Animation FadeAlphaTo(float alpha, double duration)
Parameters
Returns
- Animation
Animation object that can be executed on a Node
FadeAlphaTo(float, TimeSpan)
Animate new alpha of node
public static Animation FadeAlphaTo(float alpha, TimeSpan duration)
Parameters
Returns
- Animation
Animation object that can be executed on a Node
FadeIn(double)
Change the alpha to 1.0
public static Animation FadeIn(double duration)
Parameters
duration
doubleduration in seconds
Returns
- Animation
Animation object that can be executed on a Node
FadeIn(TimeSpan)
Change the alpha to 1.0
public static Animation FadeIn(TimeSpan duration)
Parameters
duration
TimeSpanduration
Returns
- Animation
Animation object that can be executed on a Node
FadeOut(double)
Change the alpha to 0.0
public static Animation FadeOut(double duration)
Parameters
duration
doubleDuration in seconds
Returns
- Animation
Animation object that can be executed on a Node
FadeOut(TimeSpan)
Change the alpha to 0.0
public static Animation FadeOut(TimeSpan duration)
Parameters
duration
TimeSpanDuration
Returns
- Animation
Animation object that can be executed on a Node
GetHashCode()
Animation GetHashCode
public override int GetHashCode()
Returns
Group(params Animation[])
Create an Animation that groups a set of other animations, The animations will run in parallel (e.g Rotate + Fade at the same time)
public static Animation Group(params Animation[] animations)
Parameters
animations
Animation[]Array of animations to be grouped
Returns
- Animation
Animation object that can be executed on a Node
Hide()
Hide the node
public static Animation Hide()
Returns
- Animation
Animation object that can be executed on a Node
LookAt(PointF, double)
Rotate node facing target point
public static Animation LookAt(PointF target, double duration)
Parameters
Returns
LookAt(PointF, TimeSpan)
Rotate node facing target point
public static Animation LookAt(PointF target, TimeSpan duration)
Parameters
Returns
MoveBy(Vector2, double)
Move a node vertically and horizontally relative to the current position
public static Animation MoveBy(Vector2 delta, double duration)
Parameters
Returns
- Animation
Animation object that can be executed on a Node
MoveBy(Vector2, TimeSpan)
Move a node vertically and horizontally relative to the current position
public static Animation MoveBy(Vector2 delta, TimeSpan duration)
Parameters
Returns
- Animation
Animation object that can be executed on a Node
MoveBy(float, float, double)
Move a node vertically and horizontally relative to the current position
public static Animation MoveBy(float deltaX, float deltaY, double duration)
Parameters
Returns
- Animation
Animation object that can be executed on a Node
MoveBy(float, float, TimeSpan)
Move a node vertically and horizontally relative to the current position
public static Animation MoveBy(float deltaX, float deltaY, TimeSpan duration)
Parameters
Returns
- Animation
Animation object that can be executed on a Node
MoveForever(Vector2)
Move node with given velocity indefinitely
public static Animation MoveForever(Vector2 velocity)
Parameters
velocity
Vector2Velocity in points/second
Returns
MoveTo(PointF, double)
Move node to a new position
public static Animation MoveTo(PointF location, double duration)
Parameters
Returns
- Animation
Animation object that can be executed on a Node
MoveTo(PointF, TimeSpan)
Move node to a new position
public static Animation MoveTo(PointF location, TimeSpan duration)
Parameters
Returns
- Animation
Animation object that can be executed on a Node
MoveToX(float, double)
Move node horizontally
public static Animation MoveToX(float x, double duration)
Parameters
Returns
- Animation
Animation object that can be executed on a Node
MoveToX(float, TimeSpan)
Move node horizontally
public static Animation MoveToX(float x, TimeSpan duration)
Parameters
Returns
- Animation
Animation object that can be executed on a Node
MoveToY(float, double)
Move node vertically
public static Animation MoveToY(float y, double duration)
Parameters
Returns
- Animation
Animation object that can be executed on a Node
MoveToY(float, TimeSpan)
Move node vertically
public static Animation MoveToY(float y, TimeSpan duration)
Parameters
Returns
- Animation
Animation object that can be executed on a Node
MoveXBy(float, double)
Move a node horizontally relative to the current position
public static Animation MoveXBy(float deltaX, double duration)
Parameters
Returns
- Animation
Animation object that can be executed on a Node
MoveXBy(float, TimeSpan)
Move a node horizontally relative to the current position
public static Animation MoveXBy(float deltaX, TimeSpan duration)
Parameters
Returns
- Animation
Animation object that can be executed on a Node
MoveXForever(float)
Move node with given X velocity indefinitely
public static Animation MoveXForever(float xVelocity)
Parameters
xVelocity
floatSpeed in points/second
Returns
MoveYBy(float, double)
Move a node vertically relative to the current position
public static Animation MoveYBy(float deltaY, double duration)
Parameters
Returns
- Animation
Animation object that can be executed on a Node
MoveYBy(float, TimeSpan)
Move a node vertically relative to the current position
public static Animation MoveYBy(float deltaY, TimeSpan duration)
Parameters
Returns
- Animation
Animation object that can be executed on a Node
MoveYForever(float)
Move node with given Y velocity indefinitely
public static Animation MoveYForever(float yVelocity)
Parameters
yVelocity
floatSpeed in points/second
Returns
OrbitNode(Node, double, double, double)
Rotate Node around another Node
public static Animation OrbitNode(Node center, double angle, double duration, double factor = 1)
Parameters
center
Nodeangle
doubleduration
doublefactor
doubleRadius factor for the end of the orbit (1 remain same)
Returns
OrbitNode(Node, double, TimeSpan, double)
Rotate Node around another Node
public static Animation OrbitNode(Node center, double angle, TimeSpan duration, double factor = 1)
Parameters
center
Nodeangle
doubleduration
TimeSpanfactor
doubleRadius factor for the end of the orbit (1 remain same)
Returns
OrbitPoint(PointF, double, double, double)
Rotate Node around a pivot
public static Animation OrbitPoint(PointF center, double angle, double duration, double factor = 1)
Parameters
center
PointFangle
doubleduration
doublefactor
doubleRadius factor for the end of the orbit (1 remain same)
Returns
OrbitPoint(PointF, double, TimeSpan, double)
Rotate Node around a pivot
public static Animation OrbitPoint(PointF center, double angle, TimeSpan duration, double factor = 1)
Parameters
center
PointFangle
doubleduration
TimeSpanfactor
doubleRadius factor for the end of the orbit (1 remain same)
Returns
RemoveFromParent()
When performed, removed the Node from the parent.
public static Animation RemoveFromParent()
Returns
- Animation
Animation object that can be executed on a Node
Repeat(Animation, int)
Repeat animation N times
public static Animation Repeat(Animation animation, int count)
Parameters
Returns
- Animation
Animation object that can be executed on a Node
RepeatForever(Animation)
Repeat animation forever
public static Animation RepeatForever(Animation animation)
Parameters
animation
AnimationAnimation to be repeated forever
Returns
- Animation
Animation object that can be executed on a Node
ResizeTo(SizeF, double)
Resize a SpriteNode
public static Animation ResizeTo(SizeF size, double duration)
Parameters
Returns
- Animation
Animation object that can be executed on a SpriteNode
ResizeTo(SizeF, TimeSpan)
Resize a SpriteNode
public static Animation ResizeTo(SizeF size, TimeSpan duration)
Parameters
Returns
- Animation
Animation object that can be executed on a SpriteNode
ResizeToHeight(float, double)
Change SpriteNode Height
public static Animation ResizeToHeight(float height, double duration)
Parameters
Returns
- Animation
Animation object that can be executed on a SpriteNode
ResizeToHeight(float, TimeSpan)
Change SpriteNode Height
public static Animation ResizeToHeight(float height, TimeSpan duration)
Parameters
Returns
- Animation
Animation object that can be executed on a SpriteNode
ResizeToWidth(float, double)
Change SpriteNode width
public static Animation ResizeToWidth(float width, double duration)
Parameters
Returns
- Animation
Animation object that can be executed on a SpriteNode
ResizeToWidth(float, TimeSpan)
Change SpriteNode width
public static Animation ResizeToWidth(float width, TimeSpan duration)
Parameters
Returns
- Animation
Animation object that can be executed on a SpriteNode
RotateBy(double, double)
Rotate by a angle delta
public static Animation RotateBy(double radians, double duration)
Parameters
Returns
- Animation
Animation object that can be executed on a Node
RotateBy(double, TimeSpan)
Rotate by a angle delta
public static Animation RotateBy(double radians, TimeSpan duration)
Parameters
Returns
- Animation
Animation object that can be executed on a Node
RotateForever(double)
Rotate indefinitely given with angular velocity
public static Animation RotateForever(double angularVelocity)
Parameters
angularVelocity
doubleAngular velocity in radians/second
Returns
RotateTo(double, double)
Rotate to the given angle
public static Animation RotateTo(double radians, double duration)
Parameters
Returns
- Animation
Animation object that can be executed on a Node
RotateTo(double, TimeSpan)
Rotate to the given angle
public static Animation RotateTo(double radians, TimeSpan duration)
Parameters
Returns
- Animation
Animation object that can be executed on a Node
RunAction(Action)
Run a action callback
public static Animation RunAction(Action action)
Parameters
action
ActionAction to be invoked when animation is executed
Returns
- Animation
Animation object that can be executed on a Node
ScaleBy(float, double)
Animate node applying a new scale
public static Animation ScaleBy(float scale, double duration)
Parameters
Returns
- Animation
Animation object that can be executed on a Node
ScaleBy(float, TimeSpan)
Animate node applying a new scale
public static Animation ScaleBy(float scale, TimeSpan duration)
Parameters
Returns
- Animation
Animation object that can be executed on a Node
ScaleTo(SizeF, double)
Change scale to make node reach new size
public static Animation ScaleTo(SizeF size, double duration)
Parameters
Returns
- Animation
Animation object that can be executed on a Node
ScaleTo(SizeF, TimeSpan)
Change scale to make node reach new size
public static Animation ScaleTo(SizeF size, TimeSpan duration)
Parameters
Returns
- Animation
Animation object that can be executed on a Node
ScaleTo(float, double)
Set node to a new scale
public static Animation ScaleTo(float newScale, double duration)
Parameters
Returns
- Animation
Animation object that can be executed on a Node
ScaleTo(float, float, double)
Set node to a new scale
public static Animation ScaleTo(float xScale, float yScale, double duration)
Parameters
xScale
floatFinal xscale of Node
yScale
floatFinal yscale of Node
duration
doubleDuration in seconds
Returns
- Animation
Animation object that can be executed on a Node
ScaleTo(float, float, TimeSpan)
Set node to a new scale
public static Animation ScaleTo(float xScale, float yScale, TimeSpan duration)
Parameters
xScale
floatFinal xscale of Node
yScale
floatFinal yscale of Node
duration
TimeSpanDuration in seconds
Returns
- Animation
Animation object that can be executed on a Node
ScaleTo(float, TimeSpan)
Set node to a new scale
public static Animation ScaleTo(float newScale, TimeSpan duration)
Parameters
Returns
- Animation
Animation object that can be executed on a Node
ScaleXTo(float, double)
Change X scale
public static Animation ScaleXTo(float xscale, double duration)
Parameters
Returns
- Animation
Animation object that can be executed on a Node
ScaleXTo(float, TimeSpan)
Change X scale
public static Animation ScaleXTo(float xscale, TimeSpan duration)
Parameters
Returns
- Animation
Animation object that can be executed on a Node
ScaleYTo(float, double)
Change Y scale
public static Animation ScaleYTo(float yscale, double duration)
Parameters
Returns
- Animation
Animation object that can be executed on a Node
ScaleYTo(float, TimeSpan)
Change Y scale
public static Animation ScaleYTo(float yscale, TimeSpan duration)
Parameters
Returns
- Animation
Animation object that can be executed on a Node
Sequence(params Animation[])
Create a sequence animation from a list of Animations, Each animation will executed in sequence a1 -> a2 -> a3
public static Animation Sequence(params Animation[] animations)
Parameters
animations
Animation[]Array of animations
Returns
- Animation
Animation object that can be executed on a Node
SetTexture(Texture)
Set new texture to SpriteNode
public static Animation SetTexture(Texture texture)
Parameters
texture
TextureTexture to be applied to SpriteNode
Returns
- Animation
Animation object that can be executed on a SpriteNode
SetTexture(Texture, bool)
Set new texture to SpriteNode
public static Animation SetTexture(Texture texture, bool resize)
Parameters
texture
TextureTexture to be applied to SpriteNode
resize
boolFlag to control if the SpriteNode should be resized to the size of texture
Returns
- Animation
Animation object that can be executed on a SpriteNode
Shake(double)
Shake node animation
public static Animation Shake(double duration)
Parameters
duration
double
Returns
Shake(Vector2, double)
Shake node animation
public static Animation Shake(Vector2 delta, double duration)
Parameters
Returns
Shake(Vector2, TimeSpan)
Shake node animation
public static Animation Shake(Vector2 delta, TimeSpan duration)
Parameters
Returns
Shake(TimeSpan)
Shake node animation
public static Animation Shake(TimeSpan duration)
Parameters
duration
TimeSpan
Returns
SineHorizontal(float, float, double)
Oscillate node vertical position using a Sine wave
public static Animation SineHorizontal(float amplitude, float frequency, double duration)
Parameters
amplitude
floatAmplitude of sine movement
frequency
floatFrequency of oscillation
duration
doubleDuration of oscillation in seconds
Returns
SineHorizontal(float, float, TimeSpan)
Oscillate node vertical position using a Sine wave
public static Animation SineHorizontal(float amplitude, float frequency, TimeSpan duration)
Parameters
amplitude
floatAmplitude of sine movement
frequency
floatFrequency of oscillation
duration
TimeSpanDuration of oscillation
Returns
SineVertical(float, float, double)
Oscillate node vertical position using a Sine wave
public static Animation SineVertical(float amplitude, float frequency, double duration)
Parameters
amplitude
floatAmplitude of sine movement
frequency
floatFrequency of oscillation
duration
doubleDuration of oscillation in seconds
Returns
SineVertical(float, float, TimeSpan)
Oscillate node vertical position using a Sine wave
public static Animation SineVertical(float amplitude, float frequency, TimeSpan duration)
Parameters
amplitude
floatAmplitude of sine movement
frequency
floatFrequency of oscillation
duration
TimeSpanDuration of oscillation in seconds
Returns
Unhide()
Unhide node
public static Animation Unhide()
Returns
- Animation
Animation object that can be executed on a Node
Wait(double)
Wait, useful to chain with other animations (e.g Rotate then Wait then Fade Out)
public static Animation Wait(double duration)
Parameters
duration
doubleTime to wait, in seconds
Returns
- Animation
Animation object that can be executed on a Node
Wait(TimeSpan)
Wait, useful to chain with other animations (e.g Rotate then Wait then Fade Out)
public static Animation Wait(TimeSpan duration)
Parameters
duration
TimeSpan