Sprite animator. Attach this to a sprite class to animate it. More...
Inherited by tk2dUISpriteAnimator.
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. |
Sprite animator. Attach this to a sprite class to animate it.
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.
tk2dSpriteAnimationClip tk2dSpriteAnimator.GetClipByName | ( | string | name | ) |
Resolves an animation clip by name and returns a reference to it. This is a convenient alias to tk2dSpriteAnimation.GetClipByName
name | Case 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
name | Case sensitive clip name, as defined in tk2dSpriteAnimationClip. |
bool tk2dSpriteAnimator.IsPlaying | ( | string | name | ) |
Is the named clip currently active & playing?
bool tk2dSpriteAnimator.IsPlaying | ( | tk2dSpriteAnimationClip | clip | ) |
Is this clip currently active & playing?
void tk2dSpriteAnimator.Pause | ( | ) |
Pause the currently playing clip. Will do nothing if the clip is currently paused.
void tk2dSpriteAnimator.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 tk2dSpriteAnimator.Play | ( | string | name | ) |
Play the specified clip. Will not restart the clip if it is already playing.
name | Name of clip. Try to cache the animation clip Id and use that instead for performance. |
void tk2dSpriteAnimator.Play | ( | tk2dSpriteAnimationClip | clip | ) |
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.
clip | The clip to play. |
clipStartTime | Clip start time in seconds. A value of 0 will start the clip from the beginning. |
overrideFps | Overriden 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.
name | Name of clip. Try to cache the animation clip Id and use that instead for performance. |
clipStartTime | Clip 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.
clip | The clip to play. |
clipStartTime | Clip 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.
name | Name of clip. Try to cache the animation clip Id and use that instead for performance. |
frame | Frame to start playing from. |
void tk2dSpriteAnimator.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.
clip | Use GetClipByName to resolve a named clip id |
frame | Frame to start from. |
void tk2dSpriteAnimator.Resume | ( | ) |
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.
void tk2dSpriteAnimator.Stop | ( | ) |
Stop the currently playing clip.
void tk2dSpriteAnimator.StopAndResetFrame | ( | ) |
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.
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> tk2dSpriteAnimator.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.
bool tk2dSpriteAnimator.playAutomatically = false |
Interface option to play the animation automatically when instantiated / game is started. Useful for background looping animations.
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.
float tk2dSpriteAnimator.ClipTimeSeconds [get] |
The current clip time in seconds.
The currently active or playing tk2dSpriteAnimationClip
int tk2dSpriteAnimator.CurrentFrame [get] |
Returns the current frame of the animation This is a zero based index into CurrentClip.frames.
The default clip.
int tk2dSpriteAnimator.DefaultClipId [get, set] |
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.
bool tk2dSpriteAnimator.Playing [get] |
Is a clip currently playing? Will return true if the clip is playing, but is paused.
virtual tk2dBaseSprite tk2dSpriteAnimator.Sprite [get] |
Gets the sprite the animator is currently animating.