1
Support / Re: Frustration with tk2d
« on: May 07, 2014, 03:30:47 pm »
Ok some simple math did the trick.
Here is my working code for now.
I dont now if this is a clean/usual solution.
If anyone has better ideas, please povide me
with this. Btw. next step would be to write
an PlayMaker Action for this.
If someone is interested ?
Here is my working code for now.
I dont now if this is a clean/usual solution.
If anyone has better ideas, please povide me
with this. Btw. next step would be to write
an PlayMaker Action for this.
If someone is interested ?
Code: [Select]
using UnityEngine;
using System.Collections;
public class Mouse_Click : MonoBehaviour {
private tk2dSpriteAnimator animator;
private bool isAnimating = false; // Check if animation is playing, only allow revers when animation is playing
public int totalFrames; // Number of total frames in animation to match seamless reverse
// Use this for initialization
void Start () {
animator = GetComponent<tk2dSpriteAnimator>();
}
// Update is called once per frame
void Update () {
if (Input.GetMouseButtonDown(0))
{
animator.Play( animator.Library.GetClipByName("Test_Interface_Animation") );
isAnimating = true;
}
if (Input.GetMouseButtonDown(1))
{
if (isAnimating) {
animator.PlayFromFrame( animator.Library.GetClipByName("Test_Interface_Animation").Reverse(), totalFrames - animator.CurrentFrame);
isAnimating = false;
}
}
}
}