Moreover, if anybody would need isReversed flag - here it is:
public class tk2dAnimatedSprite : tk2dSprite
{
public int currFrame = 0;
public bool isReversed = false;
********
void Update ()
{
#if UNITY_EDITOR
// Don't play animations when not in play mode
if (!Application.isPlaying)
return;
#endif
if (g_paused || paused)
return;
if (currentClip != null && currentClip.frames != null)
{
clipTime += Time.deltaTime * currentClip.fps * ((isReversed)?-1:1); // modified
if (currentClip.wrapMode == tk2dSpriteAnimationClip.WrapMode.Loop || currentClip.wrapMode == tk2dSpriteAnimationClip.WrapMode.RandomLoop)
{
currFrame = (int)clipTime % currentClip.frames.Length;
if (currFrame <0) currFrame += currentClip.frames.Length; // added
SetFrameInternal(currFrame);
}
else if (currentClip.wrapMode == tk2dSpriteAnimationClip.WrapMode.LoopSection)
{
currFrame = (int)clipTime;
if (currFrame >= currentClip.loopStart)
{
currFrame = currentClip.loopStart + ((currFrame - currentClip.loopStart) % (currentClip.frames.Length - currentClip.loopStart));
}
if (currFrame <0) currFrame += currentClip.frames.Length; // added
SetFrameInternal(currFrame);
}
else if (currentClip.wrapMode == tk2dSpriteAnimationClip.WrapMode.PingPong)
{
currFrame = (int)clipTime % (currentClip.frames.Length + currentClip.frames.Length - 2);
if (currFrame >= currentClip.frames.Length)
{
int i = currFrame - currentClip.frames.Length;
currFrame = currentClip.frames.Length - 2 - i;
}
if (currFrame <0) currFrame += currentClip.frames.Length; // added
SetFrameInternal(currFrame);
}
else if (currentClip.wrapMode == tk2dSpriteAnimationClip.WrapMode.Once)
{
currFrame = (int)clipTime;
if (currFrame <0) currFrame += currentClip.frames.Length; // added
if (currFrame >= currentClip.frames.Length)
{
currentClip = null;
OnCompleteAnimation();
}
else
{
SetFrameInternal(currFrame);
}
}
}
}
"Loop" mode works fine for me. Though, not sure about other modes (especially about WrapMode.Once). But now it works like this:
if (Input.GetMouseButtonDown(0))
{
anim.isReversed = false;
}
if (Input.GetMouseButtonDown(1))
{
anim.isReversed = true;
}
Debug.Log(anim.currFrame);