Sprite animator. Attach this to a sprite class to animate it. More...

Inherited by tk2dUISpriteAnimator.

List of all members.

Public Member Functions

void Play ()
 Play the current / last played clip. If no clip has been played, the default clip is used. Will not restart the clip if it is already playing.
void Play (string name)
 Play the specified clip. Will not restart the clip if it is already playing.
void Play (tk2dSpriteAnimationClip clip)
 Play the specified clip. Will not restart the clip if it is already playing.
void PlayFromFrame (int frame)
 Play the current / last played clip. If no clip has been played, the default clip is used. Will restart the clip at frame if called while the clip is playing.
void PlayFromFrame (string name, int frame)
 Play the specified clip, starting at the frame specified. Will restart the clip at frame if called while the clip is playing.
void PlayFromFrame (tk2dSpriteAnimationClip clip, int frame)
 Play the clip specified by identifier, starting at the specified frame. Will restart the clip at frame if it is already playing.
void PlayFrom (float clipStartTime)
 Play the current / last played clip. If no clip has been played, the default clip is used. Will restart the clip at frame if called while the clip is playing.
void PlayFrom (string name, float clipStartTime)
 Play the specified clip, starting "clipStartTime" seconds into the clip. Will restart the clip at clipStartTime if called while the clip is playing.
void PlayFrom (tk2dSpriteAnimationClip clip, float clipStartTime)
 Play the clip specified by identifier. Will restart the clip at clipStartTime if called while the clip is playing.
void Play (tk2dSpriteAnimationClip clip, float clipStartTime, float overrideFps)
 Play the clip specified by identifier. Will not restart the clip if called while it is already playing unless clipStartTime is set.
void Stop ()
 Stop the currently playing clip.
void StopAndResetFrame ()
 Stops the currently playing animation and reset to the first frame in the animation.
bool IsPlaying (string name)
 Is the named clip currently active & playing?
bool IsPlaying (tk2dSpriteAnimationClip clip)
 Is this clip currently active & playing?
tk2dSpriteAnimationClip GetClipById (int id)
 Finds a named clip from the current library. Returns null if not found.
int GetClipIdByName (string name)
 Resolves an animation clip by name and returns a unique id. This is a convenient alias to tk2dSpriteAnimation.GetClipIdByName
tk2dSpriteAnimationClip GetClipByName (string name)
void Pause ()
 Pause the currently playing clip. Will do nothing if the clip is currently paused.
void Resume ()
 Resume the currently paused clip. Will do nothing if the clip hasn't been paused.
void SetFrame (int currFrame)
 Sets the current frame. The animation will wrap if the selected frame exceeds the number of frames in the clip. This variant WILL trigger an event if the current frame has a trigger defined.
void SetFrame (int currFrame, bool triggerEvent)
 Sets the current frame. The animation will wrap if the selected frame exceeds the number of frames in the clip.
void UpdateAnimation (float deltaTime)
 Steps the animation based on the given deltaTime Disable tk2dSpriteAnimator, and then call UpdateAnimation manually to feed your own time eg. when you need an animation to play when the game is paused using Time.timeScale.

Static Public Member Functions

static tk2dSpriteAnimator AddComponent (GameObject go, tk2dSpriteAnimation anim, int clipId)
 Adds a tk2dSpriteAnimator as a component to the gameObject passed in, setting up necessary parameters and building geometry.

Public Attributes

bool playAutomatically = false
 Interface option to play the animation automatically when instantiated / game is started. Useful for background looping animations.
System.Action
< tk2dSpriteAnimator,
tk2dSpriteAnimationClip
AnimationCompleted
 Animation completed callback. This is called when the animation has completed playing. Will not trigger on looped animations. Parameters (caller, currentClip) Set to null to clear.
System.Action
< tk2dSpriteAnimator,
tk2dSpriteAnimationClip, int > 
AnimationEventTriggered
 Animation callback. This is called when the frame displayed has tk2dSpriteAnimationFrame.triggerEvent set. The triggering frame index is passed through, and the eventInfo / Int / Float can be extracted. Parameters (caller, currentClip, currentFrame) Set to null to clear.

Properties

static bool g_Paused [get, set]
 Globally pause all animated sprites.
bool Paused [get, set]
 Get or set pause state on this current sprite.
tk2dSpriteAnimation Library [get, set]
 tk2dSpriteAnimation
int DefaultClipId [get, set]
 The default clip used when Play is called with out any parameters.
tk2dSpriteAnimationClip DefaultClip [get]
 The default clip.
virtual tk2dBaseSprite Sprite [get]
 Gets the sprite the animator is currently animating.
bool Playing [get]
 Is a clip currently playing? Will return true if the clip is playing, but is paused.
tk2dSpriteAnimationClip CurrentClip [get]
 The currently active or playing tk2dSpriteAnimationClip
float ClipTimeSeconds [get]
 The current clip time in seconds.
float ClipFps [get, set]
 Current frame rate of the playing clip. May have been overriden by the user. Set to 0 to default to the clips fps.
static float DefaultFps [get]
 The default Fps of the clip.
int CurrentFrame [get]
 Returns the current frame of the animation This is a zero based index into CurrentClip.frames.

Detailed Description

Sprite animator. Attach this to a sprite class to animate it.


Member Function Documentation

static tk2dSpriteAnimator tk2dSpriteAnimator.AddComponent ( GameObject  go,
tk2dSpriteAnimation  anim,
int  clipId 
) [static]

Adds a tk2dSpriteAnimator as a component to the gameObject passed in, setting up necessary parameters and building geometry.

Finds a named clip from the current library. Returns null if not found.

Resolves an animation clip by name and returns a reference to it. This is a convenient alias to tk2dSpriteAnimation.GetClipByName

Returns:
tk2dSpriteAnimationClip reference, null if not found
Parameters:
nameCase sensitive clip name, as defined in tk2dSpriteAnimationClip.
int tk2dSpriteAnimator.GetClipIdByName ( string  name)

Resolves an animation clip by name and returns a unique id. This is a convenient alias to tk2dSpriteAnimation.GetClipIdByName

Returns:
Unique Animation Clip Id.
Parameters:
nameCase sensitive clip name, as defined in tk2dSpriteAnimationClip.
bool tk2dSpriteAnimator.IsPlaying ( string  name)

Is the named clip currently active & playing?

Is this clip currently active & playing?

Pause the currently playing clip. Will do nothing if the clip is currently paused.

Play the current / last played clip. If no clip has been played, the default clip is used. Will not restart the clip if it is already playing.

void tk2dSpriteAnimator.Play ( string  name)

Play the specified clip. Will not restart the clip if it is already playing.

Parameters:
nameName of clip. Try to cache the animation clip Id and use that instead for performance.

Play the specified clip. Will not restart the clip if it is already playing.

void tk2dSpriteAnimator.Play ( tk2dSpriteAnimationClip  clip,
float  clipStartTime,
float  overrideFps 
)

Play the clip specified by identifier. Will not restart the clip if called while it is already playing unless clipStartTime is set.

Parameters:
clipThe clip to play.
clipStartTimeClip start time in seconds. A value of 0 will start the clip from the beginning.
overrideFpsOverriden framerate of clip. Set to DefaultFps to use default.
void tk2dSpriteAnimator.PlayFrom ( float  clipStartTime)

Play the current / last played clip. If no clip has been played, the default clip is used. Will restart the clip at frame if called while the clip is playing.

void tk2dSpriteAnimator.PlayFrom ( string  name,
float  clipStartTime 
)

Play the specified clip, starting "clipStartTime" seconds into the clip. Will restart the clip at clipStartTime if called while the clip is playing.

Parameters:
nameName of clip. Try to cache the animation clip Id and use that instead for performance.
clipStartTimeClip start time in seconds.
void tk2dSpriteAnimator.PlayFrom ( tk2dSpriteAnimationClip  clip,
float  clipStartTime 
)

Play the clip specified by identifier. Will restart the clip at clipStartTime if called while the clip is playing.

Parameters:
clipThe clip to play.
clipStartTimeClip start time in seconds. A value of 0 will start the clip from the beginning
void tk2dSpriteAnimator.PlayFromFrame ( int  frame)

Play the current / last played clip. If no clip has been played, the default clip is used. Will restart the clip at frame if called while the clip is playing.

void tk2dSpriteAnimator.PlayFromFrame ( string  name,
int  frame 
)

Play the specified clip, starting at the frame specified. Will restart the clip at frame if called while the clip is playing.

Parameters:
nameName of clip. Try to cache the animation clip Id and use that instead for performance.
frameFrame to start playing from.

Play the clip specified by identifier, starting at the specified frame. Will restart the clip at frame if it is already playing.

Parameters:
clipUse GetClipByName to resolve a named clip id
frameFrame to start from.

Resume the currently paused clip. Will do nothing if the clip hasn't been paused.

void tk2dSpriteAnimator.SetFrame ( int  currFrame)

Sets the current frame. The animation will wrap if the selected frame exceeds the number of frames in the clip. This variant WILL trigger an event if the current frame has a trigger defined.

void tk2dSpriteAnimator.SetFrame ( int  currFrame,
bool  triggerEvent 
)

Sets the current frame. The animation will wrap if the selected frame exceeds the number of frames in the clip.

Stop the currently playing clip.

Stops the currently playing animation and reset to the first frame in the animation.

void tk2dSpriteAnimator.UpdateAnimation ( float  deltaTime)

Steps the animation based on the given deltaTime Disable tk2dSpriteAnimator, and then call UpdateAnimation manually to feed your own time eg. when you need an animation to play when the game is paused using Time.timeScale.


Member Data Documentation

Animation completed callback. This is called when the animation has completed playing. Will not trigger on looped animations. Parameters (caller, currentClip) Set to null to clear.

Animation callback. This is called when the frame displayed has tk2dSpriteAnimationFrame.triggerEvent set. The triggering frame index is passed through, and the eventInfo / Int / Float can be extracted. Parameters (caller, currentClip, currentFrame) Set to null to clear.

Interface option to play the animation automatically when instantiated / game is started. Useful for background looping animations.


Property Documentation

float tk2dSpriteAnimator.ClipFps [get, set]

Current frame rate of the playing clip. May have been overriden by the user. Set to 0 to default to the clips fps.

The current clip time in seconds.

Returns the current frame of the animation This is a zero based index into CurrentClip.frames.

The default clip used when Play is called with out any parameters.

float tk2dSpriteAnimator.DefaultFps [static, get]

The default Fps of the clip.

bool tk2dSpriteAnimator.g_Paused [static, get, set]

Globally pause all animated sprites.

bool tk2dSpriteAnimator.Paused [get, set]

Get or set pause state on this current sprite.

Is a clip currently playing? Will return true if the clip is playing, but is paused.

Gets the sprite the animator is currently animating.