Hello Guest

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - foggery

Pages: [1]
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 ;)?

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;
}

}

}
}

2
Support / Re: Frustration with tk2d
« on: May 07, 2014, 11:49:50 am »
Hello, i know this post is old, but i have some issues with this.


I tried the extension and it works so far. But not realiy in the way i want it.

What i need is a seamless forward and backward playing.

For Example:

(Left Click -> Start Animation)  1-2-3-4-5-6-7-8-9-10 (Right Click -> Stop Animation at current frame/time -> Play Reverse/Backwards) 9-8-7-6-5 (Left Click -> Stop Animation at current frame/time -> Play Forward) 6-7-8-9-10 ...

What is it good for:

You can use it for roll-over/indicator Buttons/Animation Effects. Or for more complex interface/ui designs.

I'm not really a programmer so i hope someone can help me getting the code together. This is the code with the extension included so far. Problem is that the animation makes a jump and is not seamless. Maybe there is another easy way without the extension.

Code: [Select]
using UnityEngine;
using System.Collections;

public class Mouse_Click : MonoBehaviour {

public tk2dSpriteAnimator animator;


void Start () {
animator = GetComponent<tk2dSpriteAnimator>();
}


void Update () {

if (Input.GetMouseButtonDown(0))
{
animator.Play( animator.Library.GetClipByName("Test_Interface_Animation") );
}
if (Input.GetMouseButtonDown(1))
{
animator.Play( animator.Library.GetClipByName("Test_Interface_Animation").Reverse() );
}

}
}


Thank you!


Pages: [1]