2D Toolkit Forum

2D Toolkit => Support => Topic started by: tomy45 on June 09, 2014, 12:03:52 pm

Title: Play one animation after another
Post by: tomy45 on June 09, 2014, 12:03:52 pm
I will play one clip and then after another tap the second clip. Hope you understand.

Example: First Tap on the Ipad opens a door. The second Tap close it. How can i do this in 2D Toolkit.

Thanks for your help.


Here is the code. It play´s one clip.

using UnityEngine;
using System.Collections;

public class Door : MonoBehaviour {
   
   public tk2dSpriteAnimator DoorClip;
   
   void OnMouseDown() {   
      
      DoorClip.Play();         
   }   
   
}
Title: Re: Play one animation after another
Post by: unikronsoftware on June 09, 2014, 12:47:20 pm
You should maintain state yourself.

Code: [Select]
bool doorOpen = false;

OnMouseDown -
if (!doorOpen) {
  DoorAnimator.Play("DoorOpen");
  doorOpen = true;
}
else {
  DoorAnimator.Play("DoorClose");
  doorOpen = false;
}
Title: Re: Play one animation after another
Post by: tomy45 on June 10, 2014, 05:57:55 pm
Works ! Thanks.
But now I have the problem to reverse the animation clip. How can I do this ?
Title: Re: Play one animation after another
Post by: unikronsoftware on June 10, 2014, 10:33:03 pm
You cant, not officially anyway. Simply create a reversed version of the clip, Duplicate, then click reverse in the editor.