Otter  0.9.8.91
2d Game Development Framework based on SFML.Net
 All Classes Namespaces Functions Variables Enumerations Properties
Otter.Anim Class Reference

Class used for animations in Spritemap. More...

Public Member Functions

 Anim (int[] frames, float[] frameDelays=null)
 Creates a new Anim with an array of ints for frames, and an array of floats for frameDelays. More...
 
 Anim (string frames, string frameDelays)
 Creates a new Anim with a string of ints for frames, and a string of floats for frameDelays. More...
 
Anim Repeat (int times=-1)
 Determines how many times this animation loops. -1 for infinite. More...
 
Anim NoRepeat ()
 Disables repeating. Animations default to repeat on. More...
 
Anim PingPong (bool pingpong=true)
 Determines if the animation will repeat by going back and forth between the start and end. More...
 
Anim Speed (float speed)
 Determines the playback speed of the animation. 1 = 1 frame. More...
 
Anim LoopBackTo (int frame=0)
 Determines which frame the animation will loop back to when it repeats. More...
 
Anim Stop ()
 Stops the animation and returns it to the first frame. More...
 
Anim Reset ()
 Resets the animation back to frame 0 but does not stop it. More...
 
void Update (float t=1f)
 Updates the Anim object. Handled by the Spritemap usually. If this doesn't run the animation will not play. More...
 

Static Public Member Functions

static int[] FramesRange (int min, int max)
 Returns an array of numbers from min to max. Useful for passing in arguments for long animations. More...
 
static int[] ParseFrames (string input)
 Creates an array of frames from a string expression. The expression must be similar to the following format: "0,3,7-11,2,5" Whitespace is permitted, and commas are optional.

Parameters
inputA string formatted as above, describing the frames to generate.
More...
 

Public Attributes

Action OnComplete = delegate { }
 An action to run when the animation finishes playing. More...
 
Action OnNewFrame = delegate { }
 An action that is called when the Anim switches to a new frame. More...
 
bool Active
 Determines if the animation is active (playing.) More...
 

Properties

float PlaybackSpeed [get, set]
 The overall playback speed of the animation. More...
 
int RepeatCount [get, set]
 The repeat count of the animation. More...
 
List< int > Frames [get, set]
 The frames used in the animation. More...
 
List< float > FrameDelays [get, set]
 The frame delays used in the animation. More...
 
int FrameCount [get]
 The total number of frames in this animation. More...
 
int CurrentFrame [get]
 The current frame of the animation. More...
 
int CurrentFrameIndex [get, set]
 The current frame index of the animation. More...
 
float TotalDuration [get]
 The total duration of the animation. More...
 

Detailed Description

Class used for animations in Spritemap.

Constructor & Destructor Documentation

Otter.Anim.Anim ( int[]  frames,
float[]  frameDelays = null 
)

Creates a new Anim with an array of ints for frames, and an array of floats for frameDelays.

Parameters
framesThe frames from the sprite sheet to display.
frameDelaysThe time that each frame should be displayed.
Otter.Anim.Anim ( string  frames,
string  frameDelays 
)

Creates a new Anim with a string of ints for frames, and a string of floats for frameDelays.

Parameters
framesA string of frames separated by a delim character. Example: "0,1,2-7,9,11"
frameDelaysA string of floats separated by a delim character. Example: "0.5f,1,0.5f,1"
delimThe string of characters to parse the string by. Default is ","

Member Function Documentation

static int [] Otter.Anim.FramesRange ( int  min,
int  max 
)
static

Returns an array of numbers from min to max. Useful for passing in arguments for long animations.

Parameters
minThe start of the animation (includes this number.)
maxThe end of the animation (includes this number.)
Returns
The array of ints representing an animation.
Anim Otter.Anim.LoopBackTo ( int  frame = 0)

Determines which frame the animation will loop back to when it repeats.

Parameters
frameThe frame to loop back to (from 0 to frame count - 1)
Returns
The anim object.
Anim Otter.Anim.NoRepeat ( )

Disables repeating. Animations default to repeat on.

Returns
The anim object.
static int [] Otter.Anim.ParseFrames ( string  input)
static

Creates an array of frames from a string expression. The expression must be similar to the following format: "0,3,7-11,2,5" Whitespace is permitted, and commas are optional.

Parameters
inputA string formatted as above, describing the frames to generate.

Anim Otter.Anim.PingPong ( bool  pingpong = true)

Determines if the animation will repeat by going back and forth between the start and end.

Parameters
pingpongTrue for yes, false for no no no.
Returns
The anim object.
Anim Otter.Anim.Repeat ( int  times = -1)

Determines how many times this animation loops. -1 for infinite.

Parameters
timesHow many times the animation should repeat.
Returns
The anim object.
Anim Otter.Anim.Reset ( )

Resets the animation back to frame 0 but does not stop it.

Returns
The anim object.
Anim Otter.Anim.Speed ( float  speed)

Determines the playback speed of the animation. 1 = 1 frame.

Parameters
speedThe new speed.
Returns
The anim object.
Anim Otter.Anim.Stop ( )

Stops the animation and returns it to the first frame.

Returns
The anim object.
void Otter.Anim.Update ( float  t = 1f)

Updates the Anim object. Handled by the Spritemap usually. If this doesn't run the animation will not play.

Parameters
tThe time scale.

Member Data Documentation

bool Otter.Anim.Active

Determines if the animation is active (playing.)

Action Otter.Anim.OnComplete = delegate { }

An action to run when the animation finishes playing.

Action Otter.Anim.OnNewFrame = delegate { }

An action that is called when the Anim switches to a new frame.

Property Documentation

int Otter.Anim.CurrentFrame
get

The current frame of the animation.

int Otter.Anim.CurrentFrameIndex
getset

The current frame index of the animation.

int Otter.Anim.FrameCount
get

The total number of frames in this animation.

List<float> Otter.Anim.FrameDelays
getset

The frame delays used in the animation.

List<int> Otter.Anim.Frames
getset

The frames used in the animation.

float Otter.Anim.PlaybackSpeed
getset

The overall playback speed of the animation.

int Otter.Anim.RepeatCount
getset

The repeat count of the animation.

float Otter.Anim.TotalDuration
get

The total duration of the animation.


The documentation for this class was generated from the following file: